1

could not make NavigationView fully extend Y-direction. Tried .edgesIgnoringSafeArea(.all) and all options of .frame(). Preview Provider shows that everything's cool, but Simulator and a real device show the opposite. (Pics attached)

The code:

import SwiftUI
struct ContentView: View {
        var body: some View {
        NavigationView{
            ZStack{
                Color.blue
                VStack{
                    Text("Hello, World!")
                        .foregroundColor(Color.blue)
                        .fontWeight(.bold)
                        .font(.system(size: 36))
                }
            }
            .navigationBarHidden(true)
            .navigationBarTitle("")
            .navigationBarBackButtonHidden(true)
            .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .center)
            .edgesIgnoringSafeArea(.all)
        }
    }
}

enter image description here

ArthyBlack
  • 41
  • 7
  • Works fine with Xcode 11.4 / iOS 13.4 – Asperi May 07 '20 at 17:38
  • Thanks, but I don't really see why this works fine for you. I've got under the hood Xcode Version 11.4.1 and devices with iOS 13.4.1, let alone the bajillion of Simulators – ArthyBlack May 08 '20 at 14:47

2 Answers2

1

Ok, I don't see any reason why it should not work, but... try to change location of modifiers, like below

NavigationView{
    ZStack{
        Color.blue
        VStack{
            Text("Hello, World!")
                .foregroundColor(Color.blue)
                .fontWeight(.bold)
                .font(.system(size: 36))
        }
    }
    .navigationBarHidden(true)
    .navigationBarTitle("")
    .navigationBarBackButtonHidden(true)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.edgesIgnoringSafeArea(.all)

Asperi
  • 228,894
  • 20
  • 464
  • 690
0

I've finally figured this out. The problem has nothing to do with NavigationView or any view at all. It turned out to be the matter of mandatory presence of a xib-file (e.g. Launch Screen) in a project. In the question I neglected to mention that I'd removed all .storyboard files. Here's the link for more:

My question was a dud in the first place, I'm sorry.

ArthyBlack
  • 41
  • 7