Chris, the only solution is to use CALayers. This is definitely the only solution.
OSX NSViews (September 2010) are easy to use: siblings do not work properly. One or the other will be randomly displayed on top.
To repeat, the problem is siblings .
To test this: using NSViews and / or nsimageviews. Make an application with a view that is one large image (1000x1000). In the view, place three or four small images / NSView here and there. Now add another 1000x1000 large image. Build and run the application again - you will see that it is simply broken. Often the lower (small) layers appear on top of a large cover layer. if you enable layer support in NSViews, it will not help, no matter what combination you try. So, the final test.
You need to give up NSViews and use CALayers and what it is.
The only annoyance with CALayers is that you cannot use IB to customize your material. You must set all the positions of the layer in the code,
yy = [CALayer layer]; yy.frame = CGRectMake(300,300, 300,300);
Make only one NSView, which is only designed to hold your first CALayer (possibly called "back"), and then just put all your CALayers in the rear.
rear = [CALayer layer]; rear.backgroundColor = CGColorCreateGenericRGB( 0.75, 0.75, 0.75, 1.0 ); [yourOnlyNsView setLayer:rear]; // these two lines must be in this order [yourOnlyNsView setWantsLayer:YES]; // these two lines must be in this order [rear addSublayer:rr]; [rear addSublayer:yy]; [yy addSublayer:s1]; [yy addSublayer:s2]; [yy addSublayer:s3]; [yy addSublayer:s4]; [rear addSublayer:tt]; [rear addSublayer:ff];
everything works perfectly, you can nest and group everything you want, and it all works flawlessly with everything that should be correctly shown above / below everything that should appear above / below, regardless of the complexity of your structure. You can later do something for the layers or shuffle things differently,
-(void) shuff { [CATransaction begin]; [CATransaction setValue:[NSNumber numberWithFloat:0.0f] forKey:kCATransactionAnimationDuration]; if .. [rear insertSublayer:ff below:yy]; else [rear insertSublayer:ff above:yy]; [CATransaction commit]; }
(The only reason for the annoying zero-second wrapper for everything you do is to prevent the animation that is provided to you for free - if you don't want the animation!)
By the way, in this quote from Apple
For performance reasons, Cocoa does not force clipping to sibling views or guarantees invalidation and drawing behavior when sisters match.
Their next suggestion ...
If you want to front view, you must make a front view a subview (or descendant) of the rear view.
Pretty much pointless (you can't replace siblings with subtitles, and the obvious error described in the above test still exists).
So these are CALayers! Enjoy it!