我正在创建一个图像,然后保存到用户相机卷。我想在图像中添加一些文本。我应该将字符串添加到UILabel,然后将其转换为图像吗?
你的建议是什么?谢谢。(我用的是斯威夫特)
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)
最佳答案
您想使用NSAttributedString drawInRect
。
关于ios - 将UILabel添加到图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26680734/