Text view

Posted on January 18, 2020

The text structure in SwiftUI is a view that displays lines of text. Various modifiers are available to customize the appearance and style of text.

text view

import SwiftUI

struct ContentView: View {
    var body: some View {
         VStack {
            Text("Hello World")
            Text("Hello World").bold()
            Text("Hello World").italic()
            Text("Hello World").foregroundColor(.red)
            Text("Hello World").fontWeight(.ultraLight)
            Text("Hello World").underline()
            Text("Hello World").underline(true, color: .red)
            Text("Hello World").strikethrough()
            Text("Hello World").strikethrough(true, color: .green)
            Text("Hello > ").foregroundColor(.green) + Text("World").foregroundColor(.blue)
         .frame(width: 400, height: 300)


Gavin Wiggins © 2020