我有一个 SwiftUI 视图,它是一个圆形视图,点击时会打开,并且应该延伸到 UI 的右侧。我如何确保它会出现在其他用户界面的顶部?其他 UI 元素是使用 ForEach 循环创建的。我尝试了 zindex 但它不起作用。我缺少什么?
ZStack {
VStack(alignment: .leading) {
Text("ALL WORKSTATIONS")
ZStack {
ChartBackground()
HStack(alignment: .bottom, spacing: 15.0) {
ForEach(Array(zip(1..., dataPoints)), id: \.1.id) { number, point in
VStack(alignment: .center, spacing: 5) {
DataCircle().zIndex(10)
ChartBar(percentage: point.percentage).zIndex(-1)
Text(point.month)
.font(.caption)
}
.frame(width: 25.0, height: 200.0, alignment: .bottom)
.animation(.default)
}
}
.offset(x: 30, y: 20)
}
.frame(width: 500, height: 300, alignment: .center)
}
}
}
}
Run Code Online (Sandbox Code Playgroud) swiftui ×1