Objective c 如何创建类似MAC升级通知的面板?
就像这样,在右上角,就像OSX升级通知一样。Objective c 如何创建类似MAC升级通知的面板?,objective-c,macos,cocoa,Objective C,Macos,Cocoa,就像这样,在右上角,就像OSX升级通知一样。 我试过NSAlert,cor NSPanel,但失败了。我想知道如何创建它,或者它不是系统类?您要查找的类是NSUserNotification,您可以在显示通知之前设置通知的标题和说明 在这些选项上玩一点,让它们适合你 顺便说一句:有两种样式的NSUserNotification可用。简单的和有动作的。不幸的是,每个应用程序只能使用一种类型,因为此值是在.plist文件中设置的 以下是我不久前编写的一些代码,用于通过NSUserNotifactio
我试过NSAlert,cor NSPanel,但失败了。我想知道如何创建它,或者它不是系统类?您要查找的类是
NSUserNotification
,您可以在显示通知之前设置通知的标题和说明
在这些选项上玩一点,让它们适合你
顺便说一句:有两种样式的NSUserNotification
可用。简单的和有动作的。不幸的是,每个应用程序只能使用一种类型,因为此值是在.plist文件中设置的
以下是我不久前编写的一些代码,用于通过NSUserNotifactionCenter显示错误通知:
- (void)postErrorNotificationWithTitle:(NSString *)title subtitle (NSString*)subtitle description:(NSString *)description {
NSUserNotification* userNoti = [[NSUserNotification alloc] init]; //create the notification with all its information
userNoti.title = title;
userNoti.subtitle = subtitle;
userNoti.informativeText = description;
NSBeep(); //create error sound
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNoti]; //Add and remove the notification from the notification center, we only want to display it
[[NSUserNotificationCenter defaultUserNotificationCenter] removeDeliveredNotification:userNoti];
}
请添加更多详细信息。到目前为止你到底试过什么?