iosswiftswiftuiios13xcode11

iOS SwiftUI: ScrollView ignore top safe area


I have a shared view in my app that can be called in different places. The root of this view is a scroll view, but sometimes it ignores the top safe area and it collapses under the navigation bar.

Here two screenshots that shows better the problem:

enter image description here enter image description here

As you can see in the second screenshot the scrollview extends for all the screen collapsing under the navigation. How can I avoid this?


Solution

  • Solved using:

    .navigationViewStyle(StackNavigationViewStyle())
    

    in all the NavigationView