Skip to content

Instantly share code, notes, and snippets.

@jwilling

jwilling/CustomClipView.m

Last active Oct 12, 2015
Embed
What would you like to do?
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