Skip to content

Instantly share code, notes, and snippets.

@jwilling
Last active October 12, 2015 09:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwilling/4004164 to your computer and use it in GitHub Desktop.
Save jwilling/4004164 to your computer and use it in GitHub Desktop.
NSTableView with custom clip view
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (!self) return nil;
self.layer = [CAScrollLayer layer];
self.wantsLayer = YES;
self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawNever;
return self;
}
- (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