實例方法
tab
tabItem(_:)
設置與此視圖關聯的選項卡欄項目。
聲明
func tabItem<V>(_ label: () -> V) -> some View where V : View
參數
label
與此視圖關聯的選項卡欄項目。
詳述
使用 tabItem(_:)
將視圖配置為 TabView
中的選項卡欄項目。下麵的示例在 TabView
中添加兩個視圖作為選項卡:
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")
}
}
}
}
可用版本
iOS 13.0+, iPadOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 7.0+
相關用法
- Swift Optional task(priority:_:)用法及代碼示例
- Swift Optional tag(_:)用法及代碼示例
- Swift Optional task(id:priority:_:)用法及代碼示例
- Swift Optional textSelection(_:)用法及代碼示例
- Swift Optional toolbar(id:content:)用法及代碼示例
- Swift Optional tint(_:)用法及代碼示例
- Swift Optional toolbar(content:)用法及代碼示例
- Swift Optional textContentType(_:)用法及代碼示例
- Swift Optional touchBarItemPresence(_:)用法及代碼示例
- Swift Optional touchBar(_:)用法及代碼示例
- Swift Optional touchBar(content:)用法及代碼示例
- Swift Optional toggleStyle(_:)用法及代碼示例
- Swift Optional transaction(_:)用法及代碼示例
- Swift Optional textInputAutocapitalization(_:)用法及代碼示例
- Swift Optional touchBarCustomizationLabel(_:)用法及代碼示例
- Swift Optional truncationMode(_:)用法及代碼示例
- Swift Optional transformEffect(_:)用法及代碼示例
- Swift Optional touchBarItemPrincipal(_:)用法及代碼示例
- Swift Optional symbolVariant(_:)用法及代碼示例
- Swift Optional popover(isPresented:attachmentAnchor:arrowEdge:content:)用法及代碼示例
- Swift Optional mask(alignment:_:)用法及代碼示例
- Swift Optional listSectionSeparatorTint(_:edges:)用法及代碼示例
- Swift Optional badge(_:)用法及代碼示例
- Swift Optional fullScreenCover(isPresented:onDismiss:content:)用法及代碼示例
- Swift Optional keyboardType(_:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Optional tabItem(_:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。