How do I draw a badge on my Dock icon using Cocoa?

后端 未结 3 1950
悲&欢浪女
悲&欢浪女 2021-01-31 09:52

How do I add a badge to the Dock icon for my app using Cocoa? Is there any roughly \"standardized\" way to do this?

(I\'m referring to the kind of badges that show up i

3条回答
  •  日久生厌
    2021-01-31 10:20

    It should be noted that NSDockTile is only available on Leopard. If you need to target Tiger you'll need to use -setApplicationIconImage: on your NSApplication object and draw your badge by hand.

    Also, it's not in the documentation outside of the release notes that I could find but you get your application's dock tile by sending the dockTile message to your NSApplication object.

    NSDockTile *tile = [[NSApplication sharedApplication] dockTile];
    [tile setBadgeLabel:@"Lots"];
    

提交回复
热议问题