gur*_*gui 6 swift swiftui geometryreader
我想使用 GeometryReader 来使用一些计算。没有我的设计看起来应该:
var body: some View {
ZStack {
Color(#colorLiteral(red: 0.117543973, green: 0.2897527516, blue: 0.4028342962, alpha: 1)).edgesIgnoringSafeArea(.all)
VStack {
HStack(spacing: self.spacing) { // todo auch berechnen?
ForEach(self.chartValues, id: \.self) { point in
DataPoint(width: 200)
}
}.animation(.default)
}
}
}
Run Code Online (Sandbox Code Playgroud)
添加后,每条线的高度都相互重叠,我做错了什么:
var body: some View {
ZStack {
Color(#colorLiteral(red: 0.117543973, green: 0.2897527516, blue: 0.4028342962, alpha: 1)).edgesIgnoringSafeArea(.all)
VStack {
GeometryReader { geo in
HStack(spacing: self.spacing) { // todo auch berechnen?
ForEach(self.chartValues, id: \.self) { point in
DataPoint(width: geo.size.width)
}
}.animation(.default)
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1491 次 |
| 最近记录: |