CJH5209

- (void)clipImage

{

// 0.加载图片

UIImage *image = [UIImage imageNamed:@"阿狸头像"];

// 1.开启位图上下文,跟图片尺寸一样大

UIGraphicsBeginImageContextWithOptions(image.size, NO, 0);

// 2.设置圆形裁剪区域,正切与图片

// 2.1创建圆形的路径

UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, image.size.width, image.size.height)];

// 2.2把路径设置为裁剪区域

[path addClip];

// 3.绘制图片

[image drawAtPoint:CGPointZero];

// 4.从上下文中获取图片

UIImage *clipImage = UIGraphicsGetImageFromCurrentImageContext();

// 5.关闭上下文

UIGraphicsEndImageContext();

_imageView.image = clipImage;

}

分类:

技术点:

相关文章:

  • 2021-12-29
  • 2021-07-31
  • 2021-11-14
  • 2021-05-03
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
  • 2022-12-23
猜你喜欢
  • 2021-11-22
  • 2021-08-15
  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
相关资源
相似解决方案