- 方法一
import SwiftUI
struct BottonTabBar: View {
var body: some View {
TabView {
ContentView()
.tabItem {
Image(systemName: "list.dash")
Text("Menu")
}
MapView()
.tabItem {
Image(systemName: "square.and.pencil")
Text("Order")
}
}.edgesIgnoringSafeArea(.top)
}
}
struct BottonTabBar_Previews: PreviewProvider {
static var previews: some View {
BottonTabBar()
}
}
- 方法二
import SwiftUI
struct BottonTabBar: View {
@State var selectIndex = 0
var body: some View {
TabView(selection: $selectIndex, content: {
ContentView()
.tabItem {
Image(systemName: "list.dash")
Text("Menu")
}.tag(0)
MapView()
.tabItem {
Image(systemName: "square.and.pencil")
Text("Order")
}.tag(1)
}).accentColor(.orange)
}
}
struct BottonTabBar_Previews: PreviewProvider {
static var previews: some View {
BottonTabBar()
}
}