UIImageView不能设置圆角的解决方法

self.leftPanelView.layer.cornerRadius =10;

self.leftPanelView.clipsToBounds = YES;

设置圆角的同时,也要设置
clipsToBounds = YES

如果要设置两个圆角,而不是四个角可以使用

  1. Create a CAShapeLayer
  2. Set its path to be a CGPathRef based on view.bounds but with only two rounded corners (probably by using +[UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:])
  3. 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;
原文地址:https://www.cnblogs.com/easonoutlook/p/2807773.html