gpt4 book ai didi

ios - 将 UILabel 添加到图像

转载 作者:行者123 更新时间:2023-11-28 09:17:50 26 4
gpt4 key购买 nike

我正在创建一个图像,然后将其保存到用户的相机胶卷中。我想在图像中添加一些文字。我应该将字符串添加到 UILabel,然后将其转换为图像吗?

你有什么建议?谢谢。 (我正在使用 Swift)

    let bottomImage = UIImage(named: "Image1.png")
let topImage = UIImage(named: "Image2.png")
let anotherImage = UIImage(named: "Image3.png")

let newSize = CGSizeMake(2480, 3508)
UIGraphicsBeginImageContext(newSize)

bottomImage?.drawInRect(CGRectMake(0, 0, newSize.width/2, 500))
topImage?.drawInRect(CGRectMake(newSize.width/2, 0, newSize.width/2, 500), blendMode: kCGBlendModeNormal, alpha: 0.8)
anotherImage?.drawInRect(CGRectMake(newSize.width/2, 500, newSize.width/2, 500), blendMode: kCGBlendModeNormal, alpha: 0.8)

let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()


UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil)

最佳答案

关于ios - 将 UILabel 添加到图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26680734/

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