//*********************************************圖片剪切成圓形********************************************************//編程
//**********************************************************************笨笨編程************************************//spa
/**圖片
* parm:sourceImage:須要剪切的原圖片ip
* parm:borderWidth:剪切後的邊框寬度ci
* parm:borderColor:邊框顏色it
*/io
- (UIImage *)circleImageWithImage:(UIImage *)sourceImage borderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor{方法
CGFloat imageWidth = sourceImage.size.width + 2 * borderWidth;im
CGFloat imageHeight = sourceImage.size.height + 2 * borderWidth;di
UIGraphicsBeginImageContextWithOptions(CGSizeMake(imageWidth, imageHeight), NO, 0.0);
UIGraphicsGetCurrentContext();
CGFloat radius = (sourceImage.size.width < sourceImage.size.height?sourceImage.size.width:sourceImage.size.height)*0.5;
UIBezierPath *bezierPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(imageWidth * 0.5, imageHeight * 0.5) radius:radius startAngle:0 endAngle:M_PI * 2 clockwise:YES];
bezierPath.lineWidth = borderWidth;
[borderColor setStroke];
[bezierPath stroke];
[bezierPath addClip];
[sourceImage drawInRect:CGRectMake(borderWidth, borderWidth, sourceImage.size.width, sourceImage.size.height)];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}