我想用Swift在Mac OS上显示一些通知横幅。但是我只能在通知中心看到它们,而不是作为横幅弹出。
你有什么想法吗?这是我的简单代码:
func showNotification() -> Void {
let notification = NSUserNotification()
notification.title = "Title of notification"
notification.subtitle = "Subtitle of notification"
notification.soundName = NSUserNotificationDefaultSoundName
NSUserNotificationCenter.default.deliver(notification)
}
@IBAction func btnPressed(_ sender: NSButton) {
showNotification()
testLbl.stringValue = "Button was pressed"
}