Lui*_*uis 1 cocoa-touch objective-c ios
我是新的编程IOS应用程序,我遇到了这个问题:我在应用程序中有两个图像,我想在Twitter上发布,但Twitter只接受一张图片上传,所以我想出了制作图像A的想法+图像B只有一个图像.我已经完成了发布和调整图像处理的大小.但是,我需要帮助才能使Image A + Image B成为一个Image.有人可以帮忙吗?谢谢.

这是你可以使用的一些代码......
假设:
这两个图像具有相同的尺寸.如果您的图像尺寸不同,则必须自己使用尺寸.
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();
Run Code Online (Sandbox Code Playgroud)希望这可以帮助!
| 归档时间: |
|
| 查看次数: |
649 次 |
| 最近记录: |