toolbarBackgroundVisibility
Specifies the preferred visibility of backgrounds on a bar managed by SwiftUI.
Declaration
compose().toolbarBackgroundVisibility(
visibility: SwiftUI.Visibility,
options: {
for: SwiftUI.ToolbarPlacement[];
}
)nonisolated func toolbarBackgroundVisibility(
_ visibility: Visibility,
for bars: ToolbarPlacement...
) -> some ViewParameters
visibility*SwiftUI.VisibilityThe preferred visibility of the background of the bar.
options.for*SwiftUI.ToolbarPlacement[]
Discussion
The preferred visibility flows up to the nearest container that
renders a bar. This could be a NavigationView or TabView
in iOS, or the root view of a WindowGroup in macOS.
In iOS, a value of ToolbarPlacement.automatic makes the visibility
of a tab bar or navigation bar background depend on where a List or
ScrollView settles. For example, when aligned to the bottom edge of
of a scroll view's content, the background of a tab bar becomes
transparent.
Specify a value of Visibility.visible to ensure that the
background of a bar remains visible regardless of where any scroll
view or list stops scrolling.
This example shows a view that prefers to always have the tab bar visible when the middle tab is selected:
TabView {
FirstTab()
MiddleTab()
.toolbarBackgroundVisibility(.visible, for: .tabBar)
LastTab()
}You can provide multiple placements to customize multiple bars at once, as in the following example:
TabView {
NavigationView {
ContentView()
.toolbarBackgroundVisibility(
.visible, for: .navigationBar, .tabBar)
}
}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.