Home > database >  How do I make my image cover the status bar (ignore the safety area)
How do I make my image cover the status bar (ignore the safety area)

Time:08-20

I'm trying to make the image ignore safety areas I've tried looking on the internet and tried playing around with the code but I can't seem to figure it out. Can someone please help me?

If you don't understand what I mean. this Is what my app looks like this I what my app looks like

and this is what I would like it to look like.this is what I would like it to look like

and here's my code:

struct Home: View {
    var body: some View {
        ScrollView {
            ZStack {
                Image("Home-Slider1_Hitachi")
                    .resizable()
                    .scaledToFill()
            }
        }
    }
}  

Thanks

CodePudding user response:

Add .edgesIgnoringSafeArea(.top) behind your ScrollView.

struct Home: View {
    var body: some View {
        ScrollView {
            ZStack {
                Image("Home-Slider1_Hitachi")
                    .resizable()
                    .scaledToFill()
            }
        }
        .edgesIgnoringSafeArea(.top) 
    }
}  

If your Home view is nested into another view, the view itself (where you call it) will need that modification.

Btw. it is just ignoring the top one, you can also do .edgesIgnoringSafeArea(.all) to ignore all.

Best, Sebastian

  • Related