I want to use an image as background of my window. But there is no
way to say IB that the image should be draw first so that all
controls can be shown.
As an option to Ricky and Sean's suggestions, you could also do
something like this:
This way you don't need to add another view and add all of the
window's contents to that view. That can all go on one line, I just
broke it up to make it a little easier to read here.
To get the background to update properly, you'll also need to do this
in the window's delegate:
Cocoa is going to tile the image. If you want the image to scale or
remain centered in the window, you'll need to update the background
color image each time in the -windowDidResize: method.
Since Cocoa draws (and therefore tiles) from the lower-left corner of
the window, it probably won't behave the way you'd want it to when
resizing the window. I think you can get it to draw from the top-left
corner by messing with the window's NSGraphicsContext, but I haven't
figured out how to do that yet. Any help here would be appreciated.