animation(_:,value:) doesn't work inside TabView with tabViewStyle(.page)

View.animation(_:,value:) doesn't seem to work inside TabView with tabViewStyle(.page). There is no animation when the value changes. The same code works as expected without TabView.

I was able to reproduce on iOS 17.5 and iOS 17.2. iOS 16.4 is working correctly.

STEPS TO REPRODUCE:

  1. Run the attached code
  2. Wait for yellow to load
  3. Wait for 2 seconds for green to load (there is no animation even though there should be)
import SwiftUI

struct ContentView: View {
    @State private var loaded = false

    var body: some View {
        TabView {
            ZStack {
                if loaded {
                    Color.green
                } else {
                    Color.yellow
                }
            }
            .animation(.default, value: loaded)
            .task {
                do {
                    try await Task.sleep(for: .seconds(2))
                    loaded = true
                } catch {
                    // no-op
                }
            }
        }
        .tabViewStyle(.page)
    }
}

Has anyone else seen this behavior?

hi @okycelt ,

I tested this out with the iOS 18.1 beta too, definitely looks like a bug to me! Can you please file a bug report at https://feedbackassistant.apple.com and add the small sample.

Please paste the FB number here.

Thanks so much for bringing this up!

Sydney

animation(_:,value:) doesn't work inside TabView with tabViewStyle(.page)
 
 
Q