The tab bar item to associate with this view.
Instance Method
インスタンスメソッド
tab
tabItem(_:)
Sets the tab bar item associated with this view.
このビューと結びつけられたタブバー項目を設定します。
Availability 有効性
- iOS 13.0+
- iPadOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- watchOS 7.0+
Technology
- Swift
UI
Declaration 宣言
Parameters パラメータ
label
Discussion 議論
Use tab
to configure a view as a tab bar item in a Tab
. The example below adds two views as tabs in a Tab
:
struct View1: View {
var body: some View {
Text("View 1")
}
}
struct View2: View {
var body: some View {
Text("View 2")
}
}
struct TabItem: View {
var body: some View {
TabView {
View1()
.tabItem {
Label("Menu", systemImage: "list.dash")
}
View2()
.tabItem {
Label("Order", systemImage: "square.and.pencil")
}
}
}
}