1:利用视图的layer 的 cornerRadius 属性
UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(200, 200, 200, 200)];
imageView.image = [UIImage imageNamed:@"1"];
imageView.layer.cornerRadius = imageView.frame.size.width
2:利用CAShapeLayer 做切割。
UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(200, 200, 200, 200)];
imageView.image = [UIImage imageNamed:@"1"];
UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:imageView.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:imageView.bounds.size];
CAShapeLayer * maskLayer = [[CAShapeLayer alloc]init];
maskLayer.frame = imageView.bounds;
maskLayer.path = maskPath.CGPath;
imageView.layer.mask = maskLayer;
[self.view addSubview:imageView];
3:利用画图的形式
UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(200, 400, 200, 200)];
imageView.image = [UIImage imageNamed:@"1"];
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, NO, 1.0);
[[UIBezierPath bezierPathWithRoundedRect:imageView.bounds cornerRadius:imageView.frame.size.width]addClip];
[imageView drawRect:imageView.bounds];
imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self.view addSubview:imageView];