gpt4 book ai didi

ios - 从两个较小的 UIImage 创建 UIImage

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:19:02 26 4
gpt4 key购买 nike

我有两个 UIImage 实例。我怎样才能创建第三个 UIImage 这只是拼接在一起的两个原始图像?我想要第一张图片在顶部,第二张图片在底部,这样顶部图片的底部边缘与底部图像的顶部边缘齐平。

最佳答案

像这样的东西应该可以工作(虽然我还没有测试过)

-(UIImage *)imageWithTopImage:(UIImage *)topImage bottomImage:(UIImage *)bottomImage
{
UIGraphicsBeginImageContext(CGSizeMake(topImage.size.width, topImage.size.height + bottomImage.size.height);
[topImage drawInRect:CGRectMake(0, 0, topImage.size.width, topImage.size.height)];
[bottomImage drawInRect:CGRectMake(0, topImage.size.width, bottomImage.size.width, bottomImage.size.height)];
UIImage *combinedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return combinedImage;
}

关于ios - 从两个较小的 UIImage 创建 UIImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12625708/

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