Persistent "Jump" animation glitch in SwiftUI TabView when switching tabs. Tried everything, need help.
Hi everyone,
I'm struggling with a persistent layout/animation issue in a standard SwiftUI TabView. Every time I switch tabs, the new view doesn't just appear instantly; it seems to perform a subtle "scale 0 to 1" or "fade-in with expansion" animation. Additionally, there’s a noticeable vertical layout shift (jump) where the content (like text) appears lower for a split second and then snaps higher to its final position.
The Issue:
- Visual Glitch: The view seems to animate its entry even though no animations are explicitly defined.
- Layout Shift: Content jumps vertically after appearing. (See attached video/photos).
- Reproducibility: This happens even with the most basic setup (just a ZStack with a Color and Text).
I have already tried (None of these fixed it):
- Removing all animations: Checked for withAnimation blocks and used .animation(nil, value: selectedTab).
- Safe Area Modifiers: Removed all .ignoresSafeArea() modifiers. The issue persists with or without them.
- Custom vs Native TabBar: I initially had a custom TabBar, but I reverted to the 100% native TabView for testing. The glitch is still there.
- Hiding/Showing TabBar: Tried UITabBar.appearance().isHidden = true and the modern .toolbar(.hidden, for: .tabBar). No difference.
- Transaction blocking: Added .transaction { $0.animation = nil } to the TabView.
- View Hierarchy: Simplified the views to just a Color and a single Text. The text still jumps upwards after the tab is selected.
- NavigationStack: Added/removed NavigationStack from individual tabs to see if it was a Safe Area calculation mismatch.
The Question:
Has anyone encountered this specific "jump" in TabView? I don't want to use a custom ZStack based router because I want to keep the native TabView lifecycle. Why does a "vanilla" TabView perform this jump/scale on tab change?
Any help or deep-dive technical explanation would be much appreciated! Thanks!
Link to code:
https://pastebin.com/CL700PXf
Link to video (Slow Animations mode):
https://streamable.com/35l1fw
Link to video (Standard speed):
https://streamable.com/8vllhq