Reputation: 1224
Given the following code snippet, I can align the leading edges of the text views but how can I specify that I want them to be aligned with their leading edges yet a certain number of pixels from the left edge of the actual VStack container?
VStack {
Text("Simple Swift Guide")
.font(.title)
Text("SwiftUI Tutorials")
.font(.subheadline)
.foregroundColor(.gray)
}
.frame(maxWidth: .infinity)
.background(Color.yellow)
Upvotes: 1
Views: 98
Reputation: 258541
Here is possible approach for your snippet (if I understood your goal correctly) - alignment is external so internal VStack
content can be any.
VStack(alignment: .leading) {
Text("Simple Swift Guide")
.font(.title)
Text("SwiftUI Tutorials")
.font(.subheadline)
.foregroundColor(.gray)
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.leading, 25)
.background(Color.yellow)
Upvotes: 1