微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ios – UILocalNotification最小动作 – 一个蓝色,一个清除?

我正在调整UIlocalnotification通知操作 – 所有工作都按照我的预期进行,除了当我在我的类别中提供两个最小操作时,通过在通知中心滑动显示操作时,最右边的操作是总是蓝色的.

由于我的应用程序中的操作是相同的,我宁愿它们都是清晰的灰色,而不是一个蓝色,一个清晰.我知道我可以让它们都具有破坏性的红色,但这也是错误的,如果我明确地将破坏性设置为假,我仍然会得到一个蓝色,一个清楚.

这是一张显示我正在谈论的内容图片

enter image description here

以下是我用来制作它的代码

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)

解决方法

HiGnotification programming guide都没有建议可以设置按钮的背景颜色.我发现的最具体的参考是后者,它指出:

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐