I'm trying to figure out how to mask an NSTableView with bottom rounded corners - but only at the bottom.
In this image, no effects are applied:
In these images, you can see the corners rounded, I've used this code for the corners:
self.scrollView.wantsLayer = TRUE;
self.scrollView.layer.cornerRadius = 6;
What I cannot figure out is how to get rid of the rounded corners on the top left and top right:
I've tried a few different options to no avail:
//creating a path
//this is a category from github.com/iccir/XUIKit
NSBezierPath * path = [NSBezierPath bezierPathWithRoundedRect:self.tableView.bounds byRoundingCorners:XUIRectCornerBottomLeft|XUIRectCornerBottomRight cornerRadii:CGSizeMake(6, 6)];
CAShapeLayer * layer = [CAShapeLayer layer];
layer.fillColor = [[NSColor blackColor] CGColor];
layer.path = [path CGPath];
//attempt 1
self.scrollView.contentView.wantsLayer = TRUE;
self.scrollView.contentView.layer.mask = layer;
self.scrollView.contentView.layer.masksToBounds = TRUE;
//attempt 2
((NSView*)self.scrollView.documentView).wantsLayer = TRUE;
((NSView*)self.scrollView.documentView).layer.mask = layer;
((NSView*)self.scrollView.documentView).layer.masksToBounds = TRUE;
//attempt 3
self.scrollView.wantsLayer = TRUE;
self.scrollView.layer.mask = layer;
self.scrollView.layer.masksToBounds = TRUE;
What ends up happening is everything disappears:
Anyone have any idea how to properly handle this? Thanks!