SwiftUI Text

webBlaster58934's avatar
Published Dec 20, 2022
Contribute to Docs

The Text view can display one or more lines of text on a screen. It is useful for read-only information.

  • Learn how to build iOS applications with Swift and SwiftUI and publish them to Apples' App Store.
    • Includes 7 Courses
    • With Certificate
    • Beginner Friendly.
      13 hours

Syntax

Text("My Text")
    Modifiers here

Any information enclosed within the double quotes "..." will display on the screen.

Example

The following example adds the text,"Codecademy is Awesome!", on the display screen.

struct ContentView: View {
var body: some View {
VStack {
Text("Codecademy is Awesome!")
.bold()
}
}
}

This will display the following:

SwiftUI Text View

All contributors

Contribute to Docs

Learn SwiftUI on Codecademy

  • Learn how to build iOS applications with Swift and SwiftUI and publish them to Apples' App Store.
    • Includes 7 Courses
    • With Certificate
    • Beginner Friendly.
      13 hours