您的位置:首页 > 移动开发 > IOS开发

iOS 剪切圆形图片

2015-12-17 17:31 483 查看
使用Quartz2D来绘制图形

+(UIImage*) circleImage:(UIImage*) image withParam:(CGFloat) inset {

UIGraphicsBeginImageContext(image.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 40);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
CGRect rect = CGRectMake(inset, inset, image.size.width - inset * 2.0f, image.size.height - inset * 2.0f);
CGContextAddEllipseInRect(context, rect);
CGContextClip(context);

[image drawInRect:rect];
CGContextAddEllipseInRect(context, rect);
CGContextStrokePath(context);
UIImage *newimg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newimg;


}

通过
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: