我想使用 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)
}
}
}
}