Ok, so I've created an image in Photoshop that will align with the buttons on my app, and now I'd like to make it the background image of my window so that the characters on the image will correspond to the keys on my app (a small calculator demo app I've been working on)
Basically, instead of giving buttons Text like 1,2,3,4, etc. I've made a 3x3 map with numbers of a different font just because it will look pretty
What I'm having difficulty with now is that I can't seem to make the image the background of my window.
I created an NSImageView and I dragged the image file onto it, so I can see it now, but I can't make it the background.
Do I need to subclass the NSImageView or is there some simple method?
I'm using XCode 4, btw
Thanks!
I think you should be able to do something like:
[window setBackgroundColor:[NSColor colorWithPatternImage:[NSImage imageNamed:@"myImage.png"]]];
This is something that a layer-backed window would be good at:
[[window contentView] setWantsLayer:YES];
[[window contentView] layer].contents = myImage;
I think you stand a better chance of getting this to resize sensibly (assuming you need to) than with a pattern color.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With