CGSize finalSize = CGSizeMake(100, 100);
CGRect rect = CGRectZero;
rect.size = finalSize;
UIGraphicsBeginImageContext(finalSize);//开启一个上下文
CGContextRef ctx = UIGraphicsGetCurrentContext();//获得当前的上下文
for(){
//循环多次 将需要圆角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);
}
//对所有的路径裁剪
CGContextClip(cox);
for(){
//根据之前的路径 对每个image 画出视图
CGRect rect3 = CGRectFromString([rects objectAtIndex:count2]);
[image drawInRect:rect3];
}
//最后得到了这个整体的image
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
该代码用于 模样讨论组 头像随机排列