1.1 初始化NSUserNotification
NSUserNotification *notification = [[NSUserNotification alloc] init];//创建通知中心
notification.title = title;
notification.subtitle = subtitle;
notification.informativeText = information;
// notification.contentImage = [NSImage imageNamed: @"ladybugThumb.jpg"];
//只有当用户设置为提示模式时,才会显示按钮
notification.hasActionButton = YES;
notification.actionButtonTitle = @"确定";
notification.otherButtonTitle = @"取消";
[[NSUserNotificationCenter defaultUserNotificationCenter] scheduleNotification:notification];
//设置通知的代理
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
//通知已经提交给通知中心
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didDeliverNotification:(NSUserNotification *)notification
{
NSLog(@"收到通知");
}
//用户已经点击了通知
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
{
NSLog(@"用户点击");
}
//returen YES;强制显示(即不管通知是否过多)
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification
{
return YES;
}
MAC:NSUserNotification
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 目前通过源代码编译安装MacPorts,是唯一的在mac os x10.12 sierra上安装的方式 下载Mac...
- 这个一般是导出的时候会报的错。 1去开发者网站申请一个新的Distribution 2选择Ad Hoc 3重新导...
- 1、首先你必须有一台苹果电脑,在App store下载 苹果 OS X El Capitan 系统。大概6G多,下...
- 2015年的MacBook Pro(机械硬盘,8G内存),之前升级到Mac 10.11,但会经常的卡顿,所以一直使...