Group Group Group Group Group Group Group Group Group

Chapter 6: .multilineTextAlignment(.leading) has no effect

I use the following code in the welcome view. But when looking at the preview, “Kuchi” appears to be centered below “Welcome to”, rather than being left aligned as the image in the book suggests.

VStack {
    Text("Welcome to")
         .font(.headline)
         .bold()
     Text("Kuchi")
         .font(.largeTitle)
         .bold()
     }
     .foregroundColor(.red)
     .lineLimit(2)
     .multilineTextAlignment(.leading)
     .padding(.horizontal)
}

You don’t have multilines here, that is the problem. Change the Text of the first one to “Welcome to \n my house” for example. Then you will see differences.