Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OS X version of bringSubviewToFront:?

I need to replicate the function of bringSubviewToFront: on the iPhone, but I am programming on the Mac. How can this be done?

like image 597
Regan Avatar asked Nov 21 '10 03:11

Regan


2 Answers

Haven't actually tried this out - and there may be better ways to do it - but this should work:

NSView* superview = [view superview];  
[view removeFromSuperview];  
[superview addSubview:view];  

This will move 'view' to the front of its siblings

like image 70
Pete Rossi Avatar answered Oct 13 '22 08:10

Pete Rossi


also be sure to enable the layer for quartz rendering:

...
NSImageView *anImage = [[NSImageView alloc] initWithFrame:NSRectMake(0,0,512,512)];
[anImageView setWantsLayer:YES];
...

otherwise, your layer cannot be rendered correctly.

like image 41
valvoline Avatar answered Oct 13 '22 07:10

valvoline