Dealing with text
The SwiftUI text struct is a view that displays one or more lines of read-only text. Text structs come with a number of standard modifiers to format text. In this section, we will create a project that applies modifiers to 10 different texts.
We will also implement TextField, which is used to display an editable text interface. We will also look at SecureField. SecureField is almost identical to TextField, but masks its content for privacy.
Getting ready
Create a new SwiftUI project named FormattedText.
How to do it…
- Enclose the text in the
bodyview with aVStack:struct ContentView: View { var body: some View { VStack{ Text("Hello World") } } } - Add the
.fontWeight(.medium)modifier to the text and observe...