我已经从更大的图像中裁剪了多个图像,现在我必须将这些裁剪的图像连接起来,形成一个可以加载到单个图像视图中的新图像。
发布于 2012-03-23 18:49:48
您需要做的是创建一个图像上下文,将您的图像绘制到此上下文中,然后将此上下文转换为图像。
//create context
CGSize endImageSize = CGSizeMake(128.0, 128.0);
UIGraphicsBeginImageContext(endImageSize);
// draw images into this context
[anImage drawInRect:CGRectMake(0,0,64, 64)];
[anotherImage drawInRect:CGRectMake(64, 64, 64, 64)];
//convert context into a UIImage
UIImage *endImage = UIGraphicsGetImageFromCurrentImageContext();
//cleanup
UIGraphicsEndImageContext();也就是说,只为每个图像创建一个UIImageView可能更好。
https://stackoverflow.com/questions/9238245
复制相似问题