/**
* 图片裁剪成圆形(无边框)
*/
- (UIImage *)imageWithCornerRadius:(CGFloat)radius {
CGFloat sideLength = MAX(self.size.width, self.size.height);
CGRect rect = (CGRect){0.f, 0.f, sideLength, sideLength};
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0.0);
CGContextAddPath(UIGraphicsGetCurrentContext(),
[UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:sideLength * 0.5].CGPath);
CGContextClip(UIGraphicsGetCurrentContext());
CGFloat imgX = (sideLength - self.size.width) * 0.5;
CGFloat imgY = (sideLength - self.size.height) * 0.5;
CGRect imgRect = (CGRect){imgX, imgY, self.size};
[self drawInRect:imgRect];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}