-(UIImage*) circleImage:(UIImage*) image{
UIGraphicsBeginImageContext(image.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
CGRect rect = CGRectMake(0, 0, image.size.width , image.size.height );
CGContextAddEllipseInRect(context, rect);
CGContextClip(context);
[image drawInRect:rect];
CGContextAddEllipseInRect(context, rect);
CGContextStrokePath(context);
UIImage *newimg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newimg;
}
注意: 穿过来的 image 必须是 正方形,否则画出来的不会是圆形,而是类似 椭圆型