I have a question about change string size and font in swift. I write some strings in txt file and I printed out with my app.In this point these strings size and font very small so I want to increase. I already tried to make it attributed string but its not allow me to call write code in show at below:
@objc func handleTxt(){
let file = "\(UUID().uuidString).txt"
let orderIdStr = self.orderId.joined(separator: "\n")
let myAttribute = [ NSAttributedString.Key.font: UIFont(name: "Comfortaa-Bold", size: 21.0)! ]
let myAttrString = NSAttributedString(string: orderIdStr, attributes: myAttribute)
let contents = myAttrString
let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
let fileURL = dir.appendingPathComponent(file)
do{
try contents.write(to: fileURL, atomically: false, encoding: .utf8)
}
catch{
print("error: \(error)")
}
}
How can I change font and size of these string?