SwiftUI – NSAttributedString

While it’s true SwiftUI doesn’t currently provide easy access to NSAttributedString, you can concatenate string literals assigning attributes to each literal individually:

Text("Regular, ") + 
Text("Italic, , ").italic() + 
Text("Bold,").bold() + 
Text("Blue").foreground(.blue)

Not pretty, but it works

Leave a Reply

Your email address will not be published. Required fields are marked *