12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- //
- // KMPurchaseAlertView.swift
- // PDF Master
- //
- // Created by lizhe on 2023/7/17.
- //
- import Cocoa
- class KMPurchaseAlertView: KMBaseXibView {
- @IBOutlet weak var iconImageView: NSImageView!
- @IBOutlet weak var titleLabel: NSTextField!
- @IBOutlet weak var heightConstraint: NSLayoutConstraint!
- @IBOutlet weak var contentBackgroundView: NSView!
-
- var event: Any? = nil
- deinit {
- self.removeNotification()
- KMPrint("KMPurchaseAlertView delloc")
- }
-
- override func draw(_ dirtyRect: NSRect) {
- super.draw(dirtyRect)
- // Drawing code here.
- }
-
- static func show(view: NSView, string: String) -> KMPurchaseAlertView? {
- // if let window = NSApp.mainWindow {
- let alertView = KMPurchaseAlertView(frame: view.bounds )
- view.addSubview(alertView)
- alertView.titleLabel.stringValue = string
- alertView.dismissShow()
- return alertView
- // }
- return nil
- }
-
- func dismissShow() {
- DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 3.0) {
- NSAnimationContext.runAnimationGroup { NSAnimationContext in
- self.animator().alphaValue = 0
- self.removeFromSuperview()
- }
- }
- }
-
- override func setup() {
- self.contentBackgroundView.backgroundColor(NSColor.km_init(hex: "#000000").withAlphaComponent(1))
- self.contentBackgroundView.border(NSColor.clear, 0, 4)
- self.titleLabel.textColor = NSColor.km_init(hex: "#FFFFFF")
- self.titleLabel.font = NSFont.SFProTextRegularFont(14)
- }
-
- override func addNotification() {
- // event = NSEvent.addLocalMonitorForEvents(matching: .any) { NSEvent in
- // return nil
- // }
- }
-
- override func removeNotification() {
- // if self.event != nil {
- // NSEvent.removeMonitor(self.event as Any)
- // self.event = nil
- // }
- }
- }
- //MARK: 时间拦截
- extension KMPurchaseAlertView {
- override func mouseUp(with event: NSEvent) {
-
- }
-
- override func mouseDown(with event: NSEvent) {
-
- }
-
- override func mouseMoved(with event: NSEvent) {
-
- }
-
- override func mouseEntered(with event: NSEvent) {
-
- }
-
- override func mouseExited(with event: NSEvent) {
-
- }
- }
|