Swift UILocalNotification 显示在屏幕上

Swift UILocalNotification Display On Screen

我正在尝试在收到时在屏幕顶部显示 UILocalNotification。我创建了一个简单的通知

var notification = UILocalNotification()
notification.alertBody = "Hello World!"
notification.fireDate = NSDate(timeIntervalSinceNow: 0)
UIApplication.sharedApplication().scheduleLocalNotification(notification)

当用户在屏幕上向下滑动时,它会在“通知”部分显示,但有没有办法在应用程序 [=17] 时在屏幕顶部显示通知以提醒用户=]?

在您的 appdelegate 中执行此操作并显示警报:

func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {

}