0

I created a custom UITabBarController to avoid some of the shortfalls of SwiftUI's tab bar. See more here. Here is where I implement it:

import SwiftUI

struct HomeView: View {

    @EnvironmentObject var appState: AppState

    var body: some View {


            UITabBarWrapper([
                TabBarElement(tabBarElementItem:
                    TabBarElementItem(title: "Learn", systemImageName: "book")) {
                        NewsView()
                },


                TabBarElement(tabBarElementItem:
                    TabBarElementItem(title: "Matches", systemImageName: "heart")) {

                        MatchesTab().environmentObject(AppState())

                },

                TabBarElement(tabBarElementItem:
                    TabBarElementItem(title: "Account", systemImageName: "person")) {
                        ProfileView()
                }


            ])
            .frame(maxHeight: .infinity)
            .edgesIgnoringSafeArea(.top)
    }
}

The MatchesTab() is a NavigationView:

import SwiftUI

struct MatchesTab: View {

    @EnvironmentObject var appState: AppState

    @State private var showingCandidate = false

    var body: some View {
        NavigationView {
            if self.appState.hasTakenQuiz {
                MatchesTabDefaultView()
                    .transition(.opacity)
                    .animation(.default)

            } else {
                SplashView()

            }
        }
    }
}

For some reason, this gray space appears under the imbedded MatchesTab:

enter image description here

Another thing to note: The issue appears to be with the NavigationView. When it is removed, the gray bar goes away

It appears to be stemming from the UINavigationController: enter image description here

1 Answers1

0

I can show you how to answer that question yourself...

To figure out what that gray area is, just tap on it (on the simulator, or on your device if you're running the app on it from Xcode), flip over to Xcode...

Open Debugger From the top menu select Debug/View Debugging/Capture View Hierarchy

Right click on the field (it should be easy to find because you just selected it)

Select "Reveal in Debug Navigator"

Reveal in Navigator

Now you can click on anything on the left hand side to find more out... Debug on left

Mozahler
  • 4,958
  • 6
  • 36
  • 56
  • Thanks for your help. I actually already dissected the View hierarchy and it us stemming from the UINavigationController (the navigation view). I added screenshots to my original post. – Joshua Martinez May 09 '20 at 21:16
  • Does that help clear things up though? I'm not sure why this is happening. When I remove the `NavigationView`, everything is fine. The problem is that I need that navigation view. – Joshua Martinez May 09 '20 at 21:23