两张图片拼成上下相接的一张图片(曾经一次面试的题目)
-(UIImage *)addImage:(UIImage *)image1 toImage:(UIImage *)image2 {
//设置返回图片size(图片1的宽,图片1和2高的和)
CGSize size = CGSizeMake(image1.size.width, image1.size.height+image2.size.height);
UIGraphicsBeginImageContext(size);
// Draw image1
[image1 drawInRect:CGRectMake(0, 0, image1.size.width, image1.size.height)];
// Draw image2
[image2 drawInRect:CGRectMake(0, image1.size.height, image2.size.width, image2.size.height)];
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultingImage;
}