SwiftUI toolbar visibility transition?

I have the need to show and hide a toolbar (bottomBar) when certain conditions are met. I am able to do this via:

func toolbar(_ visibility: Visibility, for bars: ToolbarPlacement...) -> some View

However, changes to state result in the toolbar appearing immediately rather than sliding in the from the bottom of the screen like I, and iOS users in general, are used to when using:

self.navigationController.setToolbarHidden(false, animated: true)

I've tried adding a .transition() and .animation() view modifiers to the ToolbarItemGroup but no such API exists.

What do I need to do?

Answered by runloop in 730151022

Typically, this was immediately solved by using a withAnimation block around the state change that determines the visibility of the toolbar.

Accepted Answer

Typically, this was immediately solved by using a withAnimation block around the state change that determines the visibility of the toolbar.

SwiftUI toolbar visibility transition?
 
 
Q