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

来源:互联网 发布:淘宝买家退货率高后果 编辑:程序博客网 时间:2024/05/16 10:23

本文转自博客http://www.cnblogs.com/easonoutlook/archive/2012/12/07/2807773.html

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;
0 0
原创粉丝点击