Changing the currently selected SwiftUI TabView tab
struct OnboardingWizardView: View {
@State var selectedTab = 0
var body: some View {
TabView(selection: $selectedTab) {
Page1().tag(0)
Page2().tag(1)
}.tabViewStyle(PageTabViewStyle())
.onAppear(perform: {
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
withAnimation {
self.selectedTab = 1
}
}
})
}
}