(IOS)image圆角

- (UIImage*)circleImage

{

    // NO代表透明

    UIGraphicsBeginImageContextWithOptions(self.size,NO,1);

    // 获得上下文

    CGContextRef ctx = UIGraphicsGetCurrentContext();

    // 添加一个圆

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

    // 方形变圆形

    CGContextAddEllipseInRect(ctx, rect);

    // 裁剪

    CGContextClip(ctx);

    // 将图片画上去

    [selfdrawInRect:rect];

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    returnimage;

}

你可能感兴趣的:((IOS)image圆角)