ios – SwiftUI use TabView with Picker


I am attempting to make use of a Picker to vary the chosen tab.

The problem is that after I faucet on the picker, the content material modifications with out animation.

Scrolling between tabs works accurately (the picker animates accordingly).

enter image description here

struct ContentView: View {
@State var tabSelectedValue = 0

var physique: some View {

    VStack {
        
        Picker("", choice: $tabSelectedValue) {
            Textual content("First").tag(0)
            Textual content("Second").tag(1)
        }
        .pickerStyle(SegmentedPickerStyle())
        .padding()
         
        TabView(choice: $tabSelectedValue) {
         
            Textual content("Content material for first tab")
                .tag(0)
        
            Textual content("Content material for second tab")
                .tag(1)
            
            
        }
        .tabViewStyle(.web page(indexDisplayMode: .by no means))
    }
    .padding()
}

}

Leave a Reply