标签:style io color ar os sp on bs ad
- (UIImage *)roundedCornerImageWithCornerRadius:(CGFloat)cornerRadius { CGFloat w = self.size.width; CGFloat h = self.size.height; CGFloat scale = [UIScreen mainScreen].scale; // 防止圆角半径小于0,或者大于宽/高中较小值的一半。 if (cornerRadius < 0) cornerRadius = 0; else if (cornerRadius > MIN(w, h)) cornerRadius = MIN(w, h) / 2.; UIImage *image = nil; CGRect imageFrame = CGRectMake(0., 0., w, h); UIGraphicsBeginImageContextWithOptions(self.size, NO, scale); [[UIBezierPath bezierPathWithRoundedRect:imageFrame cornerRadius:cornerRadius] addClip]; [self drawInRect:imageFrame]; image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; }
标签:style io color ar os sp on bs ad
原文地址:http://www.cnblogs.com/yjg2014/p/4086949.html