defaultVisibility(_:for:)
Configures the default visibility of a tab in customizable contexts.
Declaration
nonisolated func defaultVisibility(_ visibility: Visibility, for placements: AdaptableTabBarPlacement...) -> some TabContent<Self.TabValue>
Parameters
- visibility:
The tab’s visibility.
- placements:
The locations to apply the visibility.
Discussion
The sidebarAdaptable style supports customization of the tab bar and sidebar on iPad. To enable customization, attach a TabViewCustomization to the TabView using tabViewCustomization(_:).
This modifier has no effect on other platforms or on a TabViewStyle that doesn’t support customization.
The following example shows a TabView with three tabs, one of which is hidden by default in the sidebar.
@AppStorage("MyAppTabViewCustomization")
private var customization: TabViewCustomization
TabView(selection: $selection) {
Tab("Home", systemImage: "house", value: MyTab.home) {
MyHomeView()
}
.customizationID("com.myApp.home")
Tab("Reports", systemImage: "chart.bar", value: MyTab.reports) {
MyReportsView()
}
.customizationID("com.myApp.reports")
Tab("Browse", systemImage: "list.bullet", value: MyTab.browse) {
MyBrowseView()
}
.customizationID("com.myApp.browse")
.defaultVisibility(.hidden, for: .sidebar)
}
.tabViewStyle(.sidebarAdaptable)
.tabViewCustomization($customization)