views:

12

answers:

1

I have the following code in an NSCollectionView subclass:

-(void)drawRect:(NSRect)rect {  
    if(!NSEqualRects(highlightBox,NSZeroRect)) {        
        [[NSColor colorWithCalibratedRed:1.0f green:0.2f blue:0.2f alpha:1.0f] set];    
        NSRectFillUsingOperation(NSInsetRect(tempHighlightBox, -1.0, -1.0),NSCompositeSourceOver);
        [[NSColor colorWithCalibratedRed:0.2f green:0.2f blue:1.0f alpha:0.5f] set];
        NSRectFillUsingOperation(tempHighlightBox,NSCompositeSourceOver);
    }
}

The NSRect is drawn ok, but it is behind any of the NSCollectionViews subviews and I would like it to be over the top. Is this possible?

A: 

A view is drawn first and then all its subviews are drawn over it. There is no way to draw over a subview in the drawRect: method. To do this you would also have to override the subview’s drawRect: method.

Sven
That's a shame. Thank you!
Septih