var percent: CGFloat = 0.7
var body: some View {
VStack(alignment: .leading) {
cell("Lorem")
cell("Lorem ipsum")
cell("Lorem ipsum dolor")
cell("Lorem ipsum dolor sit")
cell("Lorem ipsum dolor sit amet")
}
}
@ViewBuilder
func cell(_ string: String) -> some View {
Text(string)
.padding(.all, 5)
.background(
GeometryReader { geometry in
ZStack(alignment: .leading) {
Rectangle()
.foregroundColor(.green)
.frame(width: geometry.size.width * percent, height: geometry.size.height)
Capsule()
.stroke(Color.black, lineWidth: 1)
}
}
)
.clipShape(Capsule())
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
89 次 |
| 最近记录: |