我正在尝试构建嵌套图层菜单,例如 Sketch 或 Photoshop。Bellow 是我到目前为止所做的,使用 VStack 和 Sections to Group 图层。
import SwiftUI
struct NestedList: View {
var body: some View {
ScrollView {
VStack {
Section (header: HStack {
Image(systemName: "arrowtriangle.down")
.accentColor(.black)
Text("Layer Group 1")
}) {
HStack {
Image(systemName: "arrowtriangle.right")
.accentColor(.black)
Text("Layer 1")
}
HStack {
Image(systemName: "arrowtriangle.right")
.accentColor(.black)
Text("Layer 1")
}
}
Section (header: HStack {
Image(systemName: "arrowtriangle.down")
.accentColor(.black)
Text("Layer Group 2")
}) {
HStack {
Image(systemName: "arrowtriangle.right")
.accentColor(.black)
Text("Layer 1")
}
HStack {
Image(systemName: "arrowtriangle.right")
.accentColor(.black)
Text("Layer 1")
}
}
}
}
}
}
struct NestedList_Previews: PreviewProvider {
static var previews: some View {
NestedList()
}
}
现在我正在尝试显示/隐藏子图层,当点击分组图层箭头时:
有谁知道该怎么做?非常感谢任何帮助!:)