我想使用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)
}
}
}
添加后,每行的高度都相互重叠,是我做错了什么吗
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)
}
}
}
}