【发布时间】:2014-06-20 23:16:24
【问题描述】:
我试图弄清楚如何用底部圆角遮盖 NSTableView - 但仅限于底部。
在此图像中,未应用任何效果:
在这些图像中,您可以看到圆角,我使用以下代码来处理角:
self.scrollView.wantsLayer = TRUE;
self.scrollView.layer.cornerRadius = 6;
我想不通的是如何去掉左上角和右上角的圆角:
我尝试了几个不同的选项都无济于事:
//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;
最终发生的事情是一切都消失了:
有人知道如何正确处理这个问题吗?谢谢!
【问题讨论】:
-
滚动视图的父视图是什么?你试过把它的底角弄圆吗?它应该剪辑它包含的任何内容。
标签: cocoa nstableview nsscrollview cornerradius