Search code examples
swiftswiftuiwatchkitapple-watch

How can I make a storyboard to the left of an initial view storyboard on Apple Watch using SwiftuI?


My Goal: To make 3 views side by side, where each view takes up all of the Apple Watches viewable area. Something like Apple's workout app when it's on a current workout.

Using the stack overflow answer here I figured out how to use storyboards to make swipable views to the right of the Initial view, but how can I make a swipable view to the left of the initial storyboard view?

When I connect views with ctrl mouse from one view to another, the only segue option I get is next page, which makes a swipable view to the right.


Solution

  • Well, in SwiftUI 2.0 it looks like there is a very easy way to integrate this with a simple TabView and I'll show an example

    struct threeViewsInOne{
        
        @State private var selectedPage = 1
        
        
        var body: some View {
            TabView(selection: $selectedPage) {
                ViewA.tag(0)
                ViewB.tag(1)
                ViewC.tag(2)
            }
            .tabViewStyle(PageTabViewStyle())
        }
    }