「SwiftUI」常用的TabView

Posted by Jiaolong on 2022/04/06

Basic

struct ContentView: View {
    var body: some View {
        TabView {
            Text("Bananas 🍌🍌")
                .tabItem {
                    Image(systemName: "1.circle.fill")
                    Text("🍌🍌")
                }
            Text("Apples 🍏🍏")
                .tabItem {
                    Image(systemName: "2.square.fill")
                    Text("🍏🍏")
                }
            Text("Peaches 🍑🍑")
                .tabItem {
                    Image(systemName: "3.square.fill")
                    Text("🍑🍑")
                }
        }
        .font(.headline)
    }
}

.tabViewStyle

        .tabViewStyle(PageTabViewStyle())
        .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))

相关链接: