resetVisibility
TypeScriptresetVisibility(): voidSwift declarationmutating func resetVisibility()Resets all tab sidebar visibilities back to the default, preserving the section customizations.
struct · iOS 18.0+ · SDK 27.1
struct TabViewCustomizationThe customizations a person makes to an adaptable sidebar tab view. 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)
resetVisibility(): voidSwift declarationmutating func resetVisibility()Resets all tab sidebar visibilities back to the default, preserving the section customizations.
resetSectionOrderFor(sectionID: string): voidSwift declarationmutating func resetSectionOrder(for sectionID: String)Resets ordering back to the default for the section with `sectionID`, preserving any customized tab visibilities.
resetSectionOrder(): voidSwift declarationmutating func resetSectionOrder()Resets ordering back to the default for all sections, preserving the customized tab visibilities.
subscriptSidebarVisibility(id: string): _SwiftUICore_VisibilitySwift declarationsubscript(sidebarVisibility id: String) -> Visibility { get set }The visibility of the tab identified by its customization identifier. Visibility can be set imperatively by subscripting with the tab's id: customization[sidebarVisibility: "com.myApp.alerts"] = .hidden You can change the default visibility by using the ``TabContent/defaultVisibility(_:for:)`` with a ``AdaptableTabBarPlacement/sidebar`` placement. Tab("Alerts", systemImage: "bell", value: .alerts) { AlertsView() } .customizationID("com.myApp.alerts") .defaultVisibility(.hidden, for: .sidebar) If the ID isn't associated with a tab or the tab has not been customized, a default value of `.automatic` is returned.
subscriptTab(id: string): TabViewCustomization_TabCustomizationSwift declarationsubscript(tab id: String) -> TabViewCustomization.TabCustomization { get set }The customization of the tab, identified by its customization identifier. You can imperatively set properties by subscripting with the tab ID. The following example sets the tab's sidebar visibility: customization[tab: "com.myApp.alerts"].sidebarVisibility = .hidden
subscriptSection(id: string): TabViewCustomization_SectionCustomizationSwift declarationsubscript(section id: String) -> TabViewCustomization.SectionCustomization { get set }The customization of the section, identified by its customization identifier. Section tab order can be read by subscripting with the tab section's id: let order = customization[section: "com.myApp.categories"].tabOrder To reset the order of an individual section, use ``TabViewCustomization/SectionCustomization/resetTabOrder()``. To reset the order of all sections, use ``TabViewCustomization/resetSectionOrder()``.
subscriptSectionID(id: string): (Array<string>) | nullSwift declarationsubscript(sectionID id: String) -> [String]? { get }The customization for a section's children, identified by the section's customization identifier. Section order can be read by subscripting with the tab section's id: let order = customization[sectionID: "com.myApp.categories"] Identifiers can be associated with a `Tab` or `TabSection` using the `customizationID(_:)` modifier. TabSection("Categories") { Tab("Climate", systemImage: "fan") { ClimateView() } .customizationID("com.myApp.climate") Tab("Lights", systemImage: "lightbulb") { LightsView() } .customizationID("com.myApp.lights") } .customizationID("com.myApp.categories") If the ID isn't associated with a section or the section has not been customized, a default value of `nil` is returned.
static init(): TabViewCustomizationSwift declarationinit()Creates an empty tab sidebar customization. To set this customization on a tab view, use the ``View/tabViewCustomization(_:)`` modifier. With an empty customization, tabs will be visible according to the default builder visibilities, and sections will be ordered in the order declared in the tab view's tab builder. You can specify a default visibility for the tab in the tab bar and sidebar by attaching ``TabContent/defaultVisibility(_:for:)-17xo7`` to the tab. 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.
No declarations were skipped in this snapshot.