Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSView equivalent of UIView Clip Subviews?

Is there a way to disable clipping of subviews of NSView? In UIView there is a “clip subviews checkbox” and the backing clipToBounds property, but I cant find anything similar in Cocoa.

Here is my scenario: I have this grey dot that you can drag on the screen:

When the user drags the dot I want to show up and down arrows that I have in the background. The up arrow is outside the bounds of the NSView holding the dot and arrow.

like image 913
user961889 Avatar asked Aug 21 '12 18:08

user961889


1 Answers

You could use the [NSView frameForAlignmentRect:] method. It defines the frame which is used for the constraints based layout. The actual frame can be much larger to allow displaying the arrows when the view is moved.

Cocoa is using this feature to compensate for shadows or other parts of views which do not "count" as actual frame of a control.

From the documentation:

The constraint-based layout system uses alignment rectangles to align views, rather than their frame. This allows custom views to be aligned based on the location of their content while still having a frame that encompasses any ornamentation they need to draw around their content, such as shadows or reflections.

like image 182
Flovdis Avatar answered Nov 02 '22 23:11

Flovdis