如何使用 Cocoa 在我的 Dock 图标上绘制徽章?
如何使用 Cocoa 将徽章添加到我的应用程序的 Dock 图标? 有没有粗略的“标准化”方法来做到这一点?
(我指的是 Mail、iChat 等中显示的那种徽章,用于指示未读消息的数量等。)
Cocoa Touch 确实提供了一种这样的方法,但我还没有找到任何等效的方法对于常规的 Cocoa 应用程序。
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 in Mail, iChat etc. to indicate the number of unread messages and the like.)
Cocoa Touch does provide one such method, but I haven't been able to find any equivalent for a regular Cocoa application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
此方法和
NSDockTile
类自 Leopard 以来就已可用。Use
This method, and the
NSDockTile
class, has been available since Leopard.需要注意的是,NSDockTile 仅在 Leopard 上可用。 如果您需要以 Tiger 为目标,则需要在 NSApplication 对象上使用
-setApplicationIconImage:
并手动绘制徽章。另外,我在发行说明之外的文档中找不到它,但您可以通过将
dockTile
消息发送到 NSApplication 对象来获取应用程序的停靠图块。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< /a> 类。 一旦你看一下文档,就会发现这是不言自明的。
A quick google search turned up the NSDockTile class. Seems pretty self-explanatory once you take a gander at the documentation.