// image 分类

- (UIImage *)circleImage{

    // NO 代表透明

    UIGraphicsBeginImageContextWithOptions(self.size, NO, 1);

    // 获得上下文

    CGContextRef ctx = UIGraphicsGetCurrentContext();

    // 添加一个圆

    CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height);

    // 方形变圆形

    CGContextAddEllipseInRect(ctx, rect);

    // 裁剪

    CGContextClip(ctx);

    // 将图片画上去

    [self drawInRect:rect];

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

    return image;

}


 

 

相关文章:

  • 2021-12-18
  • 2021-11-06
  • 2022-02-15
  • 2022-12-23
  • 2021-11-25
  • 2022-12-23
  • 2021-11-15
  • 2021-05-27
猜你喜欢
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案