目前,當我創建NSUserNotification使用警報樣式它不會隱藏,除非我手動關閉它。在一定的時間後隱藏NSUserNotification
有沒有辦法可以自動關閉/隱藏2秒後說的?
NSUserNotification碼參考:
let notification:NSUserNotification = NSUserNotification()
notification.title = "Title"
notification.subtitle = "Subtitle"
notification.informativeText = "Informative text"
notification.soundName = NSUserNotificationDefaultSoundName
notification.deliveryDate = NSDate(timeIntervalSinceNow: 10)
notification.hasActionButton = false
let notificationcenter:NSUserNotificationCenter = NSUserNotificationCenter.defaultUserNotificationCenter()
notificationcenter.scheduleNotification(notification)
太棒了。謝謝。這工作完美.. –
如果你想把它留在通知中心呢? (只需刪除彈出窗口)有沒有辦法做到這一點? –