效果图
E1819704-B84B-4741-BB28-4B87A1883EDF.png
UIImageView *iamgeview =[[UIImageView alloc]initWithFrame:CGRectMake(20, 100, 200, 200)];
UIImage *image = [UIImage imageNamed:@"gougou"];
// iamgeview.image =
iamgeview.image = [self addClipWithImage:image];
[self.view addSubview:iamgeview];
-(UIImage *)addClipWithImage:(UIImage *)image{
//1、开启上下文
UIGraphicsBeginImageContextWithOptions(image.size, NO, 0);
//2、设置裁剪区域
// UIBezierPath * path = [UIBezierPath bezierPathWithOvalInRect:rect];
UIBezierPath * path = [UIBezierPath bezierPathWithRect:CGRectMake(0,0,image.size.width, image.size.height)];
[path addArcWithCenter:CGPointMake(image.size.width, 0) radius:10 startAngle:- M_PI endAngle:-M_2_PI clockwise:NO];
[path closePath];
[path addClip];
//3、绘制图片
[image drawAtPoint:CGPointZero];
//4、获取新图片
UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext();
//5、关闭上下文
UIGraphicsEndImageContext();
//6、返回新图片
return newImage;
}