tabViewCustomization
Specifies the customizations to apply to the sidebar representation of the tab view.
Declaration
compose().tabViewCustomization(
customization: Binding<SwiftUI.TabViewCustomization> | null
)nonisolated func tabViewCustomization(
_ customization: Binding<TabViewCustomization>?
) -> some ViewParameters
customization*Binding<SwiftUI.TabViewCustomization> | nullThe customization object to store user customization in.
Discussion
Only the TabViewStyle.sidebarAdaptable style supports
supports customization. Specifying a non-nil TabViewCustomization
object using this modifier enables customization.
By default, if a person hasn't made customizations, tabs appear according to the default builder visibilities and sections appear in the order you declare in the tab view's tab builder.
You can change the default visibility by using the
TabContent.defaultVisibility(_:for:) with a
AdaptableTabBarPlacement.sidebar placement.
You can change the default section order by changing the order
in the builder. If there's an existing persisted customization,
reset the order by calling
TabViewCustomization.SectionCustomization.resetTabOrder()
when you change the order.
All tabs and tab sections that support customization need to have
a customization ID. You can mark a tab as being non-customizable
by specifying a TabCustomizationBehavior.disabled behavior
in all adaptable tab bar placements
using TabContent.customizationBehavior(_:for:)-2u727.
On macOS, a default interaction is provided for reordering sections but not for controlling the visibility of individual tabs. A custom experience should be provided if desired by setting the visibility of the tab on the customization.
The following code example uses @AppStorage to automatically persist
any visibility or section order customizations a person makes.
@AppStorage
private var customization: TabViewCustomization
TabView {
Tab("Home", systemImage: "house") {
MyHomeView()
}
.customizationID("com.myApp.home")
Tab("Reports", systemImage: "chart.bar") {
MyReportsView()
}
.customizationID("com.myApp.reports")
TabSection("Categories") {
Tab("Climate", systemImage: "fan") {
ClimateView()
}
.customizationID("com.myApp.climate")
Tab("Lights", systemImage: "lightbulb") {
LightsView()
}
.customizationID("com.myApp.lights")
}
.customizationID("com.myApp.browse")
}
.tabViewStyle(.sidebarAdaptable)
.tabViewCustomization($customization)See also
More in Navigation.
- assistiveAccessNavigationIconConfigures the view's icon for purposes of navigation.
- asyncImageURLSessionA modifier that adds a URL session for asynchronous images contained in the view to use when fetching image data.
- contentToolbarPopulates the toolbar of the specified content view type with the views you provide.
- defaultAdaptableTabBarPlacementSpecifies the default placement for the tabs in a tab view using the adaptable sidebar style.
- defaultTabBarPlacementSpecifies the preferred placement for the tabs of a TabView in the TabViewStyle.sidebarAdaptable style on platforms where the tab bar cannot adapt between different representations, and only one representation can be shown.
- navigationBarBackButtonHiddenHides the navigation bar back button for the view.
- navigationBarTitleDisplayModeConfigures the title display mode for this view.
- navigationDestinationAssociates a destination view with a presented data type for use within a navigation stack.
- navigationDocumentConfigures the view's document for purposes of navigation.
- navigationLinkIndicatorVisibilityConfigures whether navigation links show a disclosure indicator.
- navigationSplitViewColumnWidthSets a fixed, preferred width for the column containing this view.
- navigationSubtitleConfigures the view's subtitle for purposes of navigation, using a localized string resource.