【问题标题】:NSUserNotification change Notification image/logo on a per-notification basisNSUserNotification 在每个通知的基础上更改通知图像/徽标
【发布时间】:2012-10-30 17:40:12
【问题描述】:

当安排一个 NSUserNotification 传送到 NSUserNotificationCenter 时,有没有办法在每个通知的基础上设置与通知一起显示的图像/徽标?

我希望为不同类型的通知显示一个稍微不同的徽标。有什么想法吗?

【问题讨论】:

    标签: objective-c cocoa osx-mountain-lion nsusernotification


    【解决方案1】:

    对于山狮来说,它不存在。 如果您愿意,可以在这里申请https://bugreport.apple.com/cgi-bin/WebObjects/RadarWeb.woa/wa/signIn

    【讨论】:

      【解决方案2】:

      您可以通过这种方式在 OSX mavericks 中轻松设置 Image。

      在 AppDelegate.h 文件中添加以下行:

      @property (copy) NSImage *contentImage NS_AVAILABLE(10_9, NA);
      

      在 AppDelegate.m 中

      notification.contentImage = [NSImage imageNamed:@"test.jpg"];
      

      【讨论】:

      • 请注意,这不会更改徽标,而是添加另一个图像。但这是我们拥有的最好的公共 API。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-26
      • 1970-01-01
      相关资源
      最近更新 更多