TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

SwiftUI Tab Bar Hiding View

Forums > SwiftUI

I've implemented the SwiftUI tab bar but I've noticed some odd behavior/properties. For instance, when I don't do anything to the initialization of the tab bar and views within, they are hidden behind the tab bar. My only workaround is placing a spacer but this a) pushes it up too much leaving a blank bit of white space in between the bar and the actual view and b) causes the view's dimensions/spacing/padding to get messed up and everything that was once evenly padded is pressed against the sides of the device

var body: some View {
        TabView(selection: $appState.selectedTab) {
            VStack {
                HomeView(allTheThings: self.appState.devicesAndManagers)
                Spacer(minLength: 8)    
            }
            .tag(ContentViewTab.home)
            .tabItem {
                Label("Home", systemImage: "house.fill")
                    .background(
                        Color.gray
                    )
            }

            VStack {
                SettingsTabView()
                Spacer()
            }
            .tag(ContentViewTab.settings)
            .tabItem {
                Label("Settings", systemImage: "gearshape.fill")
            }
        }
        .environmentObject(appState)
    }

I've tried adding photos of the screens so its easier to demonstrate but it keeps leaving the filepath instead of actually creating an image

2      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.