簡體   English   中英

NSUserNotification - 小牛隊和自定義圖像

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM