有什么方法可以使用 SwiftUI 创建 BottomBar
Is there any way to create BottomBar using SwiftUI
我想创建一个 bottom bar
应该对我的所有页面都是通用的 我在这里发布图片 我知道如何使用情节提要来做到这一点。但我找不到方法如何在 SwiftUI 中做到这一点
这种视图在 iOS 中称为标签栏,在 SwiftUI 中称为 TabView
。它是这样声明的:
var body: some View {
TabView {
Text("Favourites Screen")
.tabItem {
Image(systemName: "heart.fill")
Text("Favourites")
}
Text("Friends Screen")
.tabItem {
Image(systemName: "person.fill")
Text("Friends")
}
Text("Nearby Screen")
.tabItem {
Image(systemName: "mappin.circle.fill")
Text("Nearby")
}
}
}
我想创建一个 bottom bar
应该对我的所有页面都是通用的 我在这里发布图片
这种视图在 iOS 中称为标签栏,在 SwiftUI 中称为 TabView
。它是这样声明的:
var body: some View {
TabView {
Text("Favourites Screen")
.tabItem {
Image(systemName: "heart.fill")
Text("Favourites")
}
Text("Friends Screen")
.tabItem {
Image(systemName: "person.fill")
Text("Friends")
}
Text("Nearby Screen")
.tabItem {
Image(systemName: "mappin.circle.fill")
Text("Nearby")
}
}
}