简体   繁体   English

更改“窗口栏”上的图标Mac OS X

[英]Changing the icon on the “window bar” Mac OS X

I was wondering how I could change the icon in the "window bar" of my Mac app. 我想知道如何更改Mac应用程序“窗口栏”中的图标。 I've also added a picture of the icon I want to change, since I believe that "window bar" isn't the correct term. 我还添加了要更改图标的图片,因为我认为“窗口栏”不是正确的术语。

截图

I think it's called "proxy icon" and it's controlled by the NSWindow method setRepresentedFilename: The icon gets set automatically based on the type of the file that is represented by the icon. 我认为它被称为“代理图标”,并且由NSWindow方法setRepresentedFilename:图标根据图标所代表的文件类型自动设置。

Be aware that the icon can be dragged by the user (as a file), so only use this, as the method name suggests, to set the file that the window represents. 请注意,图标可以由用户拖动(作为文件),因此,如方法名称所建议的那样,仅使用它来设置窗口表示的文件。 If you're coming from Windows, you might be tempted to put your app icon in there. 如果您来自Windows,则可能会想将应用程序图标放在其中。 Don't. 别。

You'll want to use -setRepresentedFilename: or the other similar methods. 您将要使用-setRepresentedFilename:或其他类似方法。 I don't think you can just change the icon to anything, it has to be associated with a file. 我认为您不能仅将图标更改为任何内容,它必须与文件关联。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM