Using -setImage on NSButton

不问归期 提交于 2019-11-28 06:46:49

问题


I am trying to make an image an button (NSButton) in a Cocoa application, below is the code I am trying to use:

[mrButton setImage:(NSImage *)@"button.jpg"];

I have linked mrButton to an NSButton in interface builder and I have a file within my Xcode project called button.jpg and I was wondering how I would go about correcting this code or making an NSButton an image.

Thanks in advance!


回答1:


This should work: [mrButton setImage:[NSImage imageNamed:@"button.jpg"]];



来源:https://stackoverflow.com/questions/6929409/using-setimage-on-nsbutton

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!