I'm building a widget for iOS 14 and would like some of the content to align to the left, with some of the other content on the right. How would I do this?
Here's my code now:
ZStack {
HStack(alignment: .center, spacing: nil, content: {
VStack(alignment: .leading, spacing: nil, content: {
Text("Heading")
.zIndex(2)
.shadow(radius: 5)
Text("Subtitle")
.zIndex(1)
.shadow(radius: 2.5)
})
})
Image("Image")
.zIndex(-1)
}
This creates this:
I would like the Heading and Subtitle text aligned to the very left of the widget, so I can add more information on the center / right side.
Thanks in advance! I'm fairly new to SwiftUI, so it's all a bit of learning.
Add spacer in HStack
HStack(alignment: .center, spacing: nil, content: {
VStack(alignment: .leading, spacing: nil, content: {
Text("Heading")
.zIndex(2)
.shadow(radius: 5)
Text("Subtitle")
.zIndex(1)
.shadow(radius: 2.5)
})
Spacer() // << here !!
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With