Isam Al Zareer
Isam Al Zareer

Reputation: 55

PageTabViewStyle Right to left

I have a TabView with PageTabViewStyle as the tabViewStyle on it inside the TabView are multiple views and it works perfectly fine but I want it to start from the right then continue to the left like the first view starts from the right then swipe to the left to see the second view.

Your help is much appreciated.

Upvotes: 1

Views: 869

Answers (1)

Taeeun Kim
Taeeun Kim

Reputation: 1256

you can use this way for that.

  1. Put a tag in subview of the PageTabView
  2. put the tag of the last view in selectedTab



struct ContentView: View {
    
    // put the tag number of the last page
    @State private var selectedTab = 2
    
    var body: some View {
        VStack {
            TabView(selection: $selectedTab){
                Text("First Page")
                    .tag(0)
                Text("Second Page")
                    .tag(1)
                Text("Third Page")
                    .tag(2)
            }
            .frame(width: 300, height: 500)
            .tabViewStyle(PageTabViewStyle())
            .background(Color.purple)
            .cornerRadius(15)
        }
    }
}



enter image description here

Upvotes: 2

Related Questions