How to make NSView not clip its bounding area?

Posted by Jeremy L on Stack Overflow See other posts from Stack Overflow or by Jeremy L
Published on 2012-09-13T06:03:00Z Indexed on 2012/09/15 3:38 UTC
Read the original article Hit count: 283

Filed under:
|
|
|
|

I created an empty Cocoa app on Xcode for OS X, and added:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    self.view = [[NSView alloc] initWithFrame:NSMakeRect(100, 100, 200, 200)];
    self.view.wantsLayer = YES;
    self.view.layer = [CALayer layer];
    self.view.layer.backgroundColor = [[NSColor yellowColor] CGColor];
    self.view.layer.anchorPoint = CGPointMake(0.5, 0.5);
    self.view.layer.transform = CATransform3DMakeRotation(30 * M_PI / 180, 1, 1, 1);

    [self.window.contentView addSubview:self.view];
}

But the rotated layer's background is clipped by the view's bounding area:

enter image description here

I thought since some version of OS X and iOS, the view won't clip the content of its subviews and will show everything inside and outside? On iOS, I do see that behavior, but I wonder why it shows up like that and how to make everything show? (I am already using the most current Xcode 4.4.1 on Mountain Lion).

(note: if you try the code above, you will need to link to Quartz Core, and possibly import the quartz core header, although I wonder why I didn't import the header and it still compiles perfectly)

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about osx