UILocalNotification 最小操作——一蓝一清?

UILocalNotification Minimal Actions – One Blue, One Clear?

我正在处理 UILocalNotification 和通知操作 – 一切如我所料,除了当我在我的类别中提供两个 Minimal 操作时,通过以下方式显示操作时在通知中心滑动,最右边的动作总是蓝色的。

由于我的应用程序中的操作相同,我宁愿它们都是透明的灰色,而不是一种蓝色,一种透明。我知道我可以用 destructive 让它们都变成红色,但这也是错误的,如果我明确地将 destructive 设置为 false,我仍然会得到一个蓝色,一个透明。

这是一张展示我所说内容的图片:

这是我用来制作它的代码:

let note = UILocalNotification()

note.fireDate = NSDate(timeIntervalSinceNow: 5)
note.timeZone = NSTimeZone.defaultTimeZone()

note.alertBody = "Actions: A and B"
note.alertTitle = "Notification!"

let action1 = UIMutableUserNotificationAction()
action1.identifier = “ACTION_A"
action1.title = "A"
action1.activationMode = .Background

let action2 = UIMutableUserNotificationAction()
action2.identifier = “ACTION_B"
action2.title = "B"
action2.activationMode = .Background

let category = UIMutableUserNotificationCategory()
category.identifier = "ANSWERS_CATEGORY"
category.setActions([action1, action2], forContext: .Default)

note.category = “ACTIONS_CATEGORY"

let categories = Set(arrayLiteral: category)
let settingsRequest = UIUserNotificationSettings(forTypes: [.Alert, .Sound, .Badge], categories: categories)
UIApplication.sharedApplication().registerUserNotificationSettings(settingsRequest)

UIApplication.sharedApplication().scheduleLocalNotification(note)

两个HiG and the notification programming guide都不建议可以设置按钮的背景颜色。我找到的最具体的参考文献是后者,其中指出:

If the destructive property is NO, the action’s button appears blue; if it’s YES, the button is red.

这显然不准确,因为两个非破坏性动作并不都是蓝色的,但它暗示每个动作的颜色是由 iOS

自动设置的