[英]Mavericks NSUserNotification not sending when app not main
[英]NSUserNotification - Mavericks & Custom images
在10.9中,NSUserNotification支持一個新屬性“contentImage”,它允許在通知本身中使用圖形。 我真的希望有一種方法來篡改iTunes的通知屏幕,所以看起來好像發件人/捆綁應用程序圖標是自定義的。
但似乎該屬性只允許我正在尋找的子集,而contentImage屬性只能處理圖像:
關於變通方法的任何想法?
NSUserNotification
對於成為一個非常封閉的系統NSUserNotification
。 但是,如果您在私有API的市場中, NSConcreteUserNotification
實現了一個名為set_identityImage:
的方法set_identityImage:
。 傳遞一個有效的NSImage,並且顯示的通知的內容與iTunes橫幅完全相同。
@interface NSUserNotification (CFIPrivate)
- (void)set_identityImage:(NSImage *)image;
@end
- (void)applicationDidFinishLaunching:(NSNotification *)notif {
NSUserNotification *notification = [[NSUserNotification alloc] init];
notification.title = @"Some Title";
notification.subtitle = @"Some subtitle";
[notification set_identityImage:[NSImage imageNamed:@"CF_Logo.png"]];
[NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:notification];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.