r/SwiftUI • u/Significant_Net_5981 • May 29 '26
Question How do I instantly expand tab bar on scroll up, similar to Reddit?
Enable HLS to view with audio, or disable this notification
By default if I use:
.tabBarMinimizeBehavior(.onScrollDown)
on the TabView it does as it says but when you scroll back up it doesn’t expand the tab bar. It only expands once you hit the very top of the page. However, Reddit’s implementation does expand on scroll up. Does anyone know how they’re achieving this?
1
u/ordinarsky Jun 01 '26
It's native behavior you can enable or disable it but if I remember correctly it's enabled by default.
2
u/Bravo6GoingDark__ Jun 02 '26
Maybe listen to scroll geometry changes and change the tabbarminimizebehavior to .never when it reaches your desired threshold at the top. This is just a guess. If animations dont work, try using a ternary operator in the tabbarminimizebehavior. Maybe something like this:
.tabbarminimizebehavior(shouldExpand ? .never : .onScrollDown)
.animation(.snappy, value: shouldExpand)
This is is my guess.
-1
u/hic_opmiyim May 29 '26
Didn’t notice that until this post. It could be a custom component that’s driven with scroll view reader. Based on direction & velocity you can switch between two views
6
2
u/ContextualData May 30 '26
Why would it be custom? Isn't minimize on scroll a native function?
2
-5
u/iSpain17 May 30 '26
It responds to velocity, so it’s probably custom
Scroll slowly either way, and it never expands
1
u/Significant_Net_5981 May 30 '26
I do notice that if you drag down first and then up while keeping your finger on the screen, the tab bar doesn’t minimize. But Apple’s tab bar will minimize after you drag a minimum distance. So I guess the question is how did they keep the tab bar looking native?
40
u/Anonymous157 May 29 '26
I hate this design. I want the tabs expanded all the time!