12

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.

Kevin Reid
  • 37,492
  • 13
  • 80
  • 108
user961889
  • 351
  • 2
  • 12
  • Perhaps this is useful http://stackoverflow.com/questions/17793022/make-nsview-not-clip-subviews-outside-of-its-bounds – neoneye Sep 29 '13 at 22:42

1 Answers1

2

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.

Flovdis
  • 2,945
  • 26
  • 49