我是一个新的编程IOS应用程序,我遇到了这个问题:我想在应用程序中发布两张图片,但Twitter只接受一张图片上传,所以我想出了制作图片A的想法+ 图片 B 只有一张图片。我已经完成了发布和调整图像大小的过程。但是,我需要帮助才能使图像 A + 图像 B 只是一个图像。任何人都可以帮助?谢谢你。

我是一个新的编程IOS应用程序,我遇到了这个问题:我想在应用程序中发布两张图片,但Twitter只接受一张图片上传,所以我想出了制作图片A的想法+ 图片 B 只有一张图片。我已经完成了发布和调整图像大小的过程。但是,我需要帮助才能使图像 A + 图像 B 只是一个图像。任何人都可以帮助?谢谢你。

这是一些您可以使用的代码...
假设:
这两个图像具有相同的尺寸。如果您的图像具有不同的尺寸,您将不得不自己调整尺寸。
UIImage *girl1 = INITIALIZE_HERE;
UIImage *girl2 = INITIALIZE_HERE;
// Get the size of your images (assumed to be the same)
CGSize size = [girl1 size];
// Create a graphic context that you can draw to. You can change the size of the
// graphics context (your 'canvas') by modifying the parameters inside the
// CGSizeMake function.
UIGraphicsBeginImageContextWithOptions(CGSizeMake(size.width*2, size.height), NO, 0);
// Draw the first image to your newly created graphic context
[girl1 drawAtPoint:CGPointMake(0,0)];
// Draw your second image to your graphic context
[girl2 drawAtPoint:CGPointMake(size.width,0)];
// Get the new image from the graphic context
UIImage *theOneImage = UIGraphicsGetImageFromCurrentImageContext();
// Get rid of the graphic context
UIGraphicsEndImageContext();
希望这可以帮助!