跳转至
Structure

DefaultTabViewStyle

The default TabView style.

Declaration

struct DefaultTabViewStyle : TabViewStyle

Overview

On iOS the default TabView looks as follows: If you don't specify a tabViewStyle(_:), this is what it defaults to.

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("🍑🍑")
                }
        }
        .tabViewStyle(DefaultTabViewStyle())
        .font(.headline)
    }
}
A gif that jumps between the three text views, "Bananas 🍌🍌", "Apples 🍏🍏", and "Peaches 🍑🍑", within an iOS default style TabView by clicking the corresponding symbols on the tab-bar: each tab bar item is a filled circle with the page number above the two matching emojis corresponding to the those in the text views.

Since this is the default style, if you omit the line .tabViewStyle(DefaultTabViewStyle()), you get the same result:

struct ExampleView: 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)
    }
}
A gif that jumps between the three text views, "Bananas 🍌🍌", "Apples 🍏🍏", and "Peaches 🍑🍑", within a TabView by clicking the corresponding symbols on the tab-bar: each tab bar item is a filled circle with the page number above the two matching emojis corresponding to the those in the text views.

Availability

iOS 13.0+

macOS 10.15+

tvOS 13.0+

watchOS 7.0+

Topics


Initializer

init() Creates a default tab view style.