gpt4 book ai didi

iphone - 如何组合 UIImageViews 并在图库中另存为单个图像作为单个图像

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:22:04 28 4
gpt4 key购买 nike

在我的新 iPhone 项目中,我想组合 5 个 UIImageViews 并在图库中作为单个图像保存为单个图像。所有这 5 个图像都在同一 View 中这可能吗..?

最佳答案

这是为了将 2 张图片合并为 1 张图片,您需要将其调整为 5 张。

- (UIImage*)imageByCombiningImage:(UIImage*)firstImage withImage:(UIImage*)secondImage {
UIImage *image = nil;

CGSize newImageSize = CGSizeMake(MAX(firstImage.size.width, secondImage.size.width), MAX(firstImage.size.height, secondImage.size.height));
if (UIGraphicsBeginImageContextWithOptions != NULL) {
UIGraphicsBeginImageContextWithOptions(newImageSize, NO, [[UIScreen mainScreen] scale]);
} else {
UIGraphicsBeginImageContext(newImageSize);
}
[firstImage drawAtPoint:CGPointMake(roundf((newImageSize.width-firstImage.size.width)/2),
roundf((newImageSize.height-firstImage.size.height)/2))];
[secondImage drawAtPoint:CGPointMake(roundf((newImageSize.width-secondImage.size.width)/2),
roundf((newImageSize.height-secondImage.size.height)/2))];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return image;
}

关于iphone - 如何组合 UIImageViews 并在图库中另存为单个图像作为单个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16662733/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com