//*********************************************图片剪切成圆形********************************************************//
//**********************************************************************笨笨编程************************************//
/**
* parm:sourceImage:需要剪切的原图片
* parm:borderWidth:剪切后的边框宽度
* parm:borderColor:边框颜色
*/
- (UIImage *)circleImageWithImage:(UIImage *)sourceImage borderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor{
CGFloat imageWidth = sourceImage.size.width + 2 * borderWidth;
CGFloat imageHeight = sourceImage.size.height + 2 * borderWidth;
UIGraphicsBeginImageContextWithOptions(CGSizeMake(imageWidth, imageHeight), NO, 0.0);
UIGraphicsGetCurrentContext();
CGFloat radius = (sourceImage.size.width < sourceImage.size.height?sourceImage.size.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;
}