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)
    }
4
  • 2
    Whatever calls that view, or displays it, should be surrounded with withAnimation { callView() } Commented Apr 23, 2021 at 15:40
  • 1
    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) Commented Aug 16, 2021 at 11:09
  • @LuisAscorbe is correct, customization also doesn't work on iOS15. Commented Nov 28, 2021 at 9:22
  • 1
    Duplicate of SwiftUI: How to animate a TabView selection? Commented Nov 28, 2021 at 9:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.