CGSize finalSize = CGSizeMake(100, 100);
CGRect rect = CGRectZero;
rect.size = finalSize;
UIGraphicsBeginImageContext(finalSize);//開啟一個(gè)上下文
CGContextRef ctx = UIGraphicsGetCurrentContext();//獲得當(dāng)前的上下文
for(){
//循環(huán)多次 ?將需要圓角image的路徑加入
CGRect rect3 = CGRectFromString([rects objectAtIndex:count]);
NSLog(@"yes");
CGRect rect2 = CGRectMake(rect3.origin.x, rect3.origin.y, rect3.size.width, rect3.size.height);
CGContextAddEllipseInRect(ctx, rect2);
}
//對(duì)所有的路徑裁剪
CGContextClip(cox);
for(){
//根據(jù)之前的路徑 對(duì)每個(gè)image 畫出視圖
CGRect rect3 = CGRectFromString([rects objectAtIndex:count2]);
[image drawInRect:rect3];
}
//最后得到了這個(gè)整體的image
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
該代碼用于 模樣討論組 頭像隨機(jī)排列