I did update of Xcode, cocoa pod, alamofire, alamofireimage today,
now I have a red marque on my code about text to image.
I am a beginner with coding.
func textToImage(drawText text: NSString, inImage image: UIImage, atPoint point: CGPoint) -> UIImage {
let textColor = UIColor.red
let textFont = UIFont(name: "Arial Rounded MT Bold", size: 24)!
let scale = UIScreen.main.scale
UIGraphicsBeginImageContextWithOptions(image.size, false, scale)
let textFontAttributes = [
NSAttributedStringKey.font.rawValue: textFont,
NSAttributedStringKey.foregroundColor: textColor,
] as! [String : Any]
image.draw(in: CGRect(origin: CGPoint.zero, size: image.size))
let rect = CGRect(origin: point, size: image.size)
text.draw(in: rect, withAttributes: textFontAttributes )
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return newImage!
}
the red marque comme in ligne
text.draw(in: rect, withAttributes: textFontAttributes )
with the message: Cannot convert value of type '[String : Any]' to expected argument type '[NSAttributedStringKey : Any]?'