有没有一种方法可以仅为UIView
的左上角和右上角设置cornerRadius
?
我尝试了以下方法,但最终导致无法看到视图。
UIView *view = [[UIView alloc] initWithFrame:frame];
CALayer *layer = [CALayer layer];
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRoundedRect:frame byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight) cornerRadii:CGSizeMake(3.0, 3.0)];
layer.shadowPath = shadowPath.CGPath;
view.layer.mask = layer;
view.bounds
,而不是frame
;(2)图层应该是一个CAShapeLayer
,而不是CALayer
;(3)设置图层的path
,而不是shadowPath
。 - Kurt Revis