tabViewBottomAccessory(isEnabled:content:)
Places a view as the bottom accessory of the tab view. Use this modifier to dynamically show and hide the accessory view.
Declaration
nonisolated func tabViewBottomAccessory<Content>(isEnabled: Bool, @ViewBuilder content: () -> Content) -> some View where Content : View
Parameters
- isEnabled:
If true, the bottom accessory is shown; otherwise, the bottom accessory is hidden.
- content:
The content view of the tab view accessory.
Discussion
On iPhone, the placement of the bottom accessory depends on the tab bar size: when the tab bar is normal size, the accessory appears above it; when the tab bar is collapsed, the accessory displays inline. Use the tabViewBottomAccessoryPlacement environment value to adjust the accessory’s content based on its placement.
The following example shows a status view in the TabView bottom accessory when there’s a status update.
TabView {
Tab("Home", systemImage: "house") {
HomeView()
}
Tab("Alerts", systemImage: "bell") {
AlertsView()
}
TabSection("Categories") {
Tab("Climate", systemImage: "fan") {
ClimateView()
}
Tab("Lights", systemImage: "lightbulb") {
LightsView()
}
}
}
.tabViewBottomAccessory(isEnabled: hasStatusUpdate) {
HomeStatusView()
}