iphone - 用两个 UIImageView 保存一个图像,其中有两个图像 - ios

标签 iphone ios objective-c xcode uiimageview

这个问题在这里已经有了答案:





How can i add two uiimageview and save it to iphone photo gallery in iphone application development?

(2 个回答)


9年前关闭。




在我的应用程序中,我有两个 UIImageViews这是一个覆盖另一个。即)UIImageView-2放置在 UIImageView-1 . UIImageView-2中的图片是透明的,所以现在我有另一个图像上的图像。现在我需要将这两个保存为单个图像。在ios中可以吗?请指教..

示例 View 如下: 红色标记是网球 ImageView 中的图像。

enter image description here

最佳答案

希望以下方法对您有所帮助。

-(CGImageRef )mergedImageFromImageOne:(UIImage *)imageOne andImageTwo:(UIImage *)imageTwo
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    CGSize imageSize = imageOne.size;

    UIGraphicsBeginImageContext(sizeVideo);

    [imageOne drawInRect:CGRectMake(0,0,imageSize.width,imageSize.height)];

    [imageTwo drawInRect:CGRectMake(0,0,imageSize.width,imageSize.height) alpha:1];

    CGImageRef imageRefNew =  CGImageCreateWithImageInRect(UIGraphicsGetImageFromCurrentImageContext().CGImage, CGRectMake(0,0,imageOne.width,imageOne.height));

    UIGraphicsEndImageContext();

    [pool release];

    return imageRefNew;
}

关于iphone - 用两个 UIImageView 保存一个图像,其中有两个图像 - ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15517364/

相关文章:

ios - 发送到不可变对象(immutable对象)的变异方法 - 错误

ios - MKMapView 不显示注释点

ios - 关闭一个 View 并从 applicationDidEnterBackground 中呈现一个新 View

php - 使用 PHP 从 HTTP POST 获取图像

iphone - 使用谓词过滤数组中对象的属性

iphone - 使用公钥通过 SSH 连接到服务器

iphone - 使用 NSMutableURLRequest 进行请求

ios - NSUserDefaults 在特定时间后清除其值

ios - 无法获取 UIView 的 subview

ios - 更改 View - (void)applicationWillEnterForeground :(UIApplication *)application