Hello SwiftUI community,
I'm trying to do something that's probably easy to do but I'm stuck on it since hours. In a list, I'd like to have items composed of:

I've tried many things (alignments, aligmentguides, GeometryReader....) but didn't find the way to achieve the result above. Does anyone has an example to help me?
Thanks 🙏🏻
Here is possible solution. Tested with Xcode 11.4 / iOS 13.4

A view for List row
struct DemoCenteredNumberView: View {
var value: Int
var body: some View {
HStack {
Spacer().overlay(
Text("Text on left side")
.frame(maxWidth: .infinity, alignment: .trailing)
)
Text("\(value)").padding()
Spacer().overlay(
Text("Text on right")
.frame(maxWidth: .infinity, alignment: .leading)
)
}
}
}
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