我有两个UIImage
. 如何创建UIImage
仅将两个原始图像拼接在一起的第三个?我想要顶部的第一张图像和底部的第二张图像,这样顶部图像的底部边缘与底部图像的顶部边缘齐平。
问问题
234 次
1 回答
6
像这样的东西应该可以工作(虽然我还没有测试过)
-(UIImage *)imageWithTopImage:(UIImage *)topImage bottomImage:(UIImage *)bottomImage
{
UIGraphicsBeginImageContext(CGSizeMake(topImage.size.width, topImage.size.height + bottomImage.size.height);
[topImage drawInRect:CGRectMake(0, 0, topImage.size.width, topImage.size.height)];
[bottomImage drawInRect:CGRectMake(0, topImage.size.width, bottomImage.size.width, bottomImage.size.height)];
UIImage *combinedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return combinedImage;
}
于 2012-09-27T16:33:09.157 回答