self.leftPanelView.layer.cornerRadius =10;
self.leftPanelView.clipsToBounds = YES;
设置圆角的同时,也要设置
clipsToBounds = YES
如果要设置两个圆角,而不是四个角可以使用
- Create a
CAShapeLayer
- Set its
path
to be a CGPathRef
based on view.bounds
but with only two rounded corners (probably by using +[UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:]
)
- Set your
view.layer.mask
to be the CAShapeLayer
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;