8

I am unable to figure out how to turn off subview/sublayer clipping when my custom view is defined in Interface Builder. When I create the view programmatically, and do the setup found in many questions here on StackOverflow, it works fine for both subviews added to a view, and sublayers added to view.layer. Those things are:

((NSView*)containingWindow.contentView).wantsLayer = YES;
view.wantsLayer = YES;
view.layer.masksToBounds = NO;

Once these are done (in that order), everything works great for views that are created in code. If I do the same thing (or ANYTHING else, for that matter) for views created in IB, I get nowhere.

I have tried using a custom NSView that defines the method:

- (CALayer*)makeBackingLayer {
    CALayer* layer = [CALayer layer];
    layer.masksToBounds = NO;

    return layer;
}

- (BOOL)wantsDefaultClipping {
    return NO;
}

Doesn't help. I've also tried checking the box under "Core Animation Layer" in View Effects in IB. That didn't help either. Finally, I tried turning off constraints, just in case that was responsible. Did not work either.

Any help is appreciated. One thing I notice is that my backing layer view "masksToBounds" starts out NO, the way I set it, but when I log the view hierarchy later, it has become YES on the very same view (verified by its memory address.)

Eric apRhys
  • 316
  • 2
  • 7

1 Answers1

-4

Try:

myView.wantsDefaultClipping = NO;

and do it also for child views.

nicael
  • 18,550
  • 13
  • 57
  • 90
  • "wantsDefaultClipping" is not a property to be set, only a method that has to be implemented in the custom view. And yes, I tried that. – Eric apRhys Nov 07 '14 at 20:14
  • Yes, and the equivalent thing for CALayer (childLayer.maskstoBounds = NO;). The sole difference seems to be whether the main view is created from a NIB or done in code. – Eric apRhys Nov 07 '14 at 22:59