Hey, it might be what you’re trying to get.
HStack(alignment: .top) {
Text(i.name)
Spacer()
GeometryReader { geoProxy in
Rectangle()
.fill(i.color)
.frame(width: self.getWidth(width: geoProxy.frame(in: .global).width, value: i.percent) ,height: 10)
.offset(x: 0, y: 5) // Allows to put the rectangle on the same baseline as your text
}
Text(String(format: "\(i.percent)", "%.0f"))
.fontWeight(.bold)
.padding(.leading,10)
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: