// image 分類 - (UIImage *)circleImage{ // NO 代表透明 UIGraphicsBeginImageContextWithOptions(self.size, NO, 1); // 獲得上下文 CGContextRef ctx = UIGraphicsGetCu ...
// image 分類
- (UIImage *)circleImage{
// NO 代表透明
UIGraphicsBeginImageContextWithOptions(self.size, NO, 1);
// 獲得上下文
CGContextRef ctx = UIGraphicsGetCurrentContext();
// 添加一個圓
CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height);
// 方形變圓形
CGContextAddEllipseInRect(ctx, rect);
// 裁剪
CGContextClip(ctx);
// 將圖片畫上去
[self drawInRect:rect];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
return image;
}