Text Formatting
Text
A simple text label can be done like this:
Font example:
As you can see, properties that are part of the font itself (bold, ultralight) are pretty simple to apply. Effects that have nothing to do with the font (strikethrough, underlines), as well as labels with mixed properties must be done using Attributed Strings.
Attributed Strings
Attributed Strings allows us to mix several properties into a single label, including things that have nothing to do with font, like colors, backgrounds, shadows, strikethroughs and underlines. While a normal label would look like this:
"Hey, I'm a test label!"
A label with attributed strings could potentially look like this:
"Hey, I'm a test label!"
It's important to know that an attributed string's functionality is very limited on Storyboards. While we try to do everything by code, sometimes we have to resort to Storyboards. If your label contains properties that are not part of a font and we are in a hurry, we might ignore these properties altogether. Consider taking a look at the Guidelines to see if Apple recommends using these properties in your case.
In order to do the example above, we are going to need to create several strings and add them together.
Last updated