SwiftUI设计可折叠(伸缩)的Section

2025-02-11

如果侧边栏信息过多,可以选择用可折叠菜单, 主要参数是isExpanded

Section(isExpanded: $isExpanded){
	Text("Item 1")
	Text("Item 2")
	Text("Item 3")
}

或者用DisclosureGroup

DisclosureGroup("DisclosureGroup"){
	Text("Item 1")
	Text("Item 2")
	Text("Item 3")
}