利用UIBezierPath這個(gè)類畫(huà)出圓形圖片
- (UIImage*)drawImageWithSize:(CGSize)size imageName:(NSString *)imageName
{
// 申請(qǐng)一塊特定大小的畫(huà)布
UIGraphicsBeginImageContext(size);
// 畫(huà)出一個(gè)與畫(huà)布等大的圓
UIBezierPath *path = [UIBezierPathbezierPathWithOvalInRect:CGRectMake(0,0, size.width, size.height)];
// 將這個(gè)圓以外的部分設(shè)置為無(wú)效區(qū)
[path addClip];
UIImage *oldImage = [UIImageimageNamed:imageName];
[oldImage drawInRect:CGRectMake(0,0, size.width, size.height)];
UIImage *newImage =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
imageView.image =newImage;
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注