Using Interface Builder's System Media files in code
I have a question regarding the several images and sound files in the Media tab of IB's library: how can they be used in code?
I want change the image of a NSImageVew
to NSRevealFreestandingTemplate
, but how can I access it? I'm pretty sure there must be a better way than creating a hidden image view and pulling it from there. Any ideas?
Thank开发者_运维问答 you!
Use NSImage's imageNamed:
method to get system images. You can use any of the values found in NSImage's Constants section as the name. To get the image you specified, you would use:
[NSImage imageNamed: NSImageNameRevealFreestandingTemplate];
[imageView setImage:[NSImage imageNamed:@"NSRevealFreestandingTemplate"]];
精彩评论