【发布时间】:2015-03-18 05:50:00
【问题描述】:
我想在我的 UIView 中使用圆角样式,这是我的代码:
UIBezierPath *maskPath1 = [UIBezierPath bezierPathWithRoundedRect:self.styleView1.bounds
byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
cornerRadii:CGSizeMake(4, 4)];
CAShapeLayer *maskLayer1 = [[CAShapeLayer alloc] init];
maskLayer1.frame = self.styleView1.bounds;
maskLayer1.path = maskPath1.CGPath;
self.styleView1.layer.borderWidth = 1;
[self.styleView1.layer setBorderColor:[[UIColor lightGrayColor] CGColor]];
self.styleView1.layer.mask = maskLayer1;
效果是这样的:
角落有空白,就像Photoshop中的羽毛效果。
但我想要的是:
如何实现?
【问题讨论】:
-
我只想将
TopLeft和TopRight设置为圆角,所以这两个线程可能不适合我的问题。 -
@Don_Chen 试试这个 (stackoverflow.com/questions/25616382/…) 和 (stackoverflow.com/questions/10167266/…)