SwiftUI TabView Animation Not giving any animation
Asked Answered
W

0

6

I'm trying to create a TabView Slider in SwiftUI with 3 modals that will onboard a user. The default PageTabViewStyle() is a little basic and I'm wanting it to animate with the default slide speed etc.

I've tried appending animation along with the transition from what I've seen online including StackOverflow but it doesn't work.

Here's what I currently have:

ZStack {
        Color.black
        TabView(selection: $currentTab) {
                ForEach(OnboardingData.list) { viewData in
                    OnboardingModal(data: viewData)
                        .tag(viewData.id)
                }
           }
            .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
            .animation(.easeInOut)
            .transition(.slide)
    }
Whirly answered 23/4, 2021 at 12:46 Comment(4)
Whatever calls that view, or displays it, should be surrounded with withAnimation { callView() }Flyspeck
From what I've seen you cannot customize the animation/transition using PageTabViewStyle on SwiftUI as of iOS 14 (I haven't tried on 15)That
@LuisAscorbe is correct, customization also doesn't work on iOS15.Assembly
Duplicate of SwiftUI: How to animate a TabView selection?Assembly

© 2022 - 2024 — McMap. All rights reserved.