Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Stack Hides Behind Tab Bar in SwiftUI

I am new to SwiftUI and using a tab bar. Inside my tab bar there are 4 views, of which I made different class for each. Now I am using a VStack for the rectangles but these rectangles hide behind the tab bar. I am attaching screenshot for this:

simulator screenshot

and here is my code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel


struct ReportIncidentView: View {
    var body: some View {
        
        ZStack(alignment: .bottom) {
            LinearGradient(gradient: Gradient(colors: [Color(ColorName.gradient1.rawValue), Color(ColorName.appBlue.rawValue)]), startPoint: .top, endPoint: .bottom)
         
            VStack(alignment: .leading) {
                
                Text("Start Questionairre")
                    .foregroundColor(.white)
                    .font(.custom(InterFont.semiBold.rawValue, size: 30))
                    .padding()
                
                VStack(spacing: -1) {
                    
                    NavigationLink(destination: HitandRunView()
                                    .navigationBarBackButtonHidden(true)
                                    .navigationBarHidden(true)
                    ){
                        reportIncidentsView(text1: "Car accident", text2: "Report accident here", corners: [.topRight])
                    }
                    
                    Rectangle()
                        .frame(height: 2)
                        .foregroundColor(Color(ColorName.emailColor.rawValue))
                    
                    NavigationLink(destination: HitandRunView()
                                    .navigationBarBackButtonHidden(true)
                                    .navigationBarHidden(true)
                    ) {
                        reportIncidentsView(text1: "Crime incidenct", text2: "Report crime here", corners: [])
                    }
                }
            }
       
        }.ignoresSafeArea()
    }
}

Can someone tell what thing has to be done so that it can come up the tab bar?

>Solution :

Try not ignoring all safe areas, only the top one:

.ignoresSafeArea(edges: .top) instead of .ignoresSafeArea()

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading