使用 UIKit 时,我们可以在前导侧或尾随侧添加多个导航栏项,但如何在 swiftUI 中做到这一点?
小智 6
你可以把它们放在HStack
这样的位置:
struct ContentView: View {
var body: some View {
NavigationView {
Text("My View")
.navigationBarTitle("My View")
.navigationBarItems(leading:
HStack {
Button("Button1") {
// action
}
Button("Button2") {
// action
}
}
)
}
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1309 次 |
最近记录: |