Avatar ·

How to create an attributed string (NSAttributedString) in Swift for UILabel?

Hi everyone! I'm a beginner in Swift and iOS development, and I've run into a problem when working with text in UILabel. I need part of the text in the label to be bold and part to be regular. For example, the string "Hello, world! This is bold text" should display like this: the word "bold" should be highlighted in bold, and the rest of the text should be regular. I know that UILabel only supports one font for the entire text via the `font` property. I tried using HTML tags inside the string, but that didn't work — the text just displays as is, with the tags. After googling, I realized I need to use `NSAttributedString`, but Apple's documentation is still a bit difficult for me. Here's an example of my code that doesn't work: ```swift let label = UILabel() label.text = "Hello, world! This bold text" label.fo