SwiftUI TabView is not working properly on Orientation Change

Viewed 196

I created a simple tabView like this

struct ContentView: View {
    var body: some View {
        TabView{
            TabItemView(color: .red, title: "Page 1")
            TabItemView(color: .yellow, title: "Page 2")
            TabItemView(color: .green, title: "Page 3")
            TabItemView(color: .blue, title: "Page 4")
        }
        .tabViewStyle(.page)
        .background(Color.indigo)
    }
}

where

struct TabItemView: View {
    var color : Color
    var title : String
    var body: some View {
        Text("\(title)")
            .frame(width:UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
            .background(color)
        
    }
}

issue is when is switch to landscape entire thing is broken , like thisLandscape View

ie the tabs are jumped back to either some random position or position between two.

I searched online and some resources say its a bug thats not solved yet . Any solution for this?

0 Answers
Related