简体   繁体   English

NSUserNotification的风格

[英]Style of NSUserNotification

A NSUserNotification only shows the action button if the user sets the style of the notifications for my app to "alerts" in the system preferences. 如果用户将我的应用的通知样式设置为系统首选项中的“警报”,则NSUserNotification仅显示操作按钮。 Can I somehow set this style for my application as a default instead of relying on the user to manually select it? 我可以以某种方式将我的应用程序的样式设置为默认值,而不是依靠用户手动选择它吗?

It took me a while to track down how to accomplish this in my own app. 我花了一段时间来追踪如何在我自己的应用程序中完成此任务。
According to Apple's info.plist keys reference : 根据Apple的info.plist键参考

NSUserNotificationAlertStyle Specifies whether the notification style should be banners , alerts , or none . NSUserNotificationAlertStyle指定通知样式应为横幅警报还是 The default value is banners, which is the recommended style. 默认值为banners,这是推荐的样式。

In your case you need to define the key NSUserNotificationAlertStyle in info.plist with the value alert . 在您的情况下,您需要在info.plist中使用值alert定义密钥NSUserNotificationAlertStyle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM