第一种:
就拿view来举例
view.layer.masksToBounds=YES; //设置为yes,就可以使用圆角
view.layer.cornerRadius= ; //设置它的圆角大小
view.layer.borderWidth=; //视图的边框宽度
view.layer.borderdg= [[UIdggray dg].CGdg]; //视图的边框颜色
第二种:
//初始化CAShapeLayer
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
//设置shapeLayer路径和圆角弧度
shapeLayer.path = [UIBezierPath bezierPathWithRoundedRect:
self.imageView.bounds cornerRadius:].CGPath;
//设置ImageView的蒙版
self.imageView.layer.mask = shapeLayer;
第三种:
-(UIImage *)getImageRadius:(CGFloat)radius andImage:(UIImage *)image{
CGFloat scale = [UIScreen mainScreen].scale;
UIGraphicsBeginImageContextWithOptions(image.size, NO, scale);
CGContextRef c = UIGraphicsGetCurrentContext();
CGRect rect = CGRectMake(, , image.size.width, image.size.height);
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:radius];
CGContextAddPath(c, path.CGPath);
CGContextClip(c);
[image drawInRect:rect];
CGContextDrawPath(c, kCGPathFillStroke);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}