Last active
October 12, 2015 09:08
-
-
Save jwilling/4004164 to your computer and use it in GitHub Desktop.
NSTableView with custom clip view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (id)initWithFrame:(NSRect)frame { | |
self = [super initWithFrame:frame]; | |
if (!self) return nil; | |
self.layer = [CAScrollLayer layer]; | |
self.wantsLayer = YES; | |
self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawNever; | |
return self; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (id)initWithFrame:(NSRect)frameRect { | |
self = [super initWithFrame:frameRect]; | |
if (self == nil) return nil; | |
[self swapClipView]; | |
return self; | |
} | |
- (void)awakeFromNib { | |
[super awakeFromNib]; | |
if (![self.contentView isKindOfClass:CustomClipView.class] ) { | |
[self swapClipView]; | |
} | |
} | |
- (void)swapClipView { | |
self.wantsLayer = YES; | |
id documentView = self.documentView; | |
CustomClipView *clipView = [[CustomClipView alloc] initWithFrame:self.contentView.frame]; | |
self.contentView = clipView; | |
self.documentView = documentView; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment