ScrollView overlapping NavigationView bar

I am noticing a bug in the following code:

// MARK: - BODY

    var body: some View {

        NavigationView {

            ScrollView(.vertical, showsIndicators: false) {

                VStack(alignment: .center, spacing: 20) {

                    // HEADER

                    FruitHeaderView(fruit: fruit)

                    VStack(alignment: .leading, spacing: 20) {

                        // TITLE

                        Text(fruit.title)

                            .font(.largeTitle)

                            .fontWeight(.heavy)

                            .foregroundColor(fruit.gradientColors[1])

                        // HEADLINE

                        Text(fruit.headline)

                            .font(.headline)

                            .multilineTextAlignment(.leading)

                        // NUTRIENTS

                        // SUBHEADLINE

                        Text("Learn more about \(fruit.title)".uppercased())

                            .fontWeight(.bold)

                            .foregroundColor(fruit.gradientColors[1])

                        // DESCRIPTION

                        Text(fruit.description)

                            .multilineTextAlignment(.leading)

                        // LINK

                        SourceLinkView(fruit: fruit)

                            .padding(.top, 10)

                            .padding(.bottom, 40)

                    } //: VSTACK

                    .padding(.horizontal, 20)

                    .frame(maxWidth: 640, alignment: .center)

                } //: VSTACK

                .navigationBarTitle(fruit.title, displayMode: .inline)

                .navigationBarHidden(true)

            } //: SCROLL

            .edgesIgnoringSafeArea(.top)

        } //: NAVIGATION

        .navigationViewStyle(StackNavigationViewStyle())

    } //: BODY

When I initially load this view, I see this after scrolling down a little:

The NavigationView bar/title is not sticking to the top and the ScrollView overlaps with it. However, if I navigate to the link at the bottom of my view (SourceLinkView), it opens the browser and then I can navigate back to my app by tapping in the status bar as usual. Upon doing this, the NavigationView bar behaves as I originally expected it to--without any overlapping of the ScrollView, like this:

I cannot figure out how to resolve this; it appears to be a bug introduced in iOS 15. I'm using Xcode 13.1 and targeting iOS 15. I believe this is an iOS 15 issue because I'm following a course on Udemy and the instructor does not have the same issue (their code/environment was written prior to iOS 15 release).

Has anyone else experienced this? I have tried several things to no avail.

I've also just noticed that I can simply swipe down from the top and after dismissing from the status bar, the NavigationView appears as it does in the second pic (normal). This is very bizarre.

When you show your code, you should better show your code as text using Code Block. With easily testable code given, more readers would try to find what's happening and how you can fix it.

Updated.

Thanks for updating. I (and possibly some other readers) will take some time to investigate. ... Sorry, but your code generates error Cannot find 'fruit' in scope and there may be more errors -- the definitions of FruitHeaderView or SourceLinkView are missing. Also you are not showing the root view (shown as < Fruits). Hard to find what's happening under the currently shown info.

I appreciate your help. Sorry about the errors, I didn't provide enough context code-wise, but I've just published my code to a public Github repo. Feel free to clone and investigate: https://github.com/cperault/fruitpedia

There might be someone who would not hesitate to dive into some external links. Better wait for such reader would find this thread. Good luck.

Hi, you've probably figured this out by now but for future reference I believe the problem is because you've included:

            .edgesIgnoringSafeArea(.top)

following your ScrollView declaration. This tells the ScrollView that it's allowed overwrite areas that are normally protected. In this case it's just ignoring the top, but that will still mean that it can overwrite the nav bar view. I can't try your code as uploaded here but I suggest you comment out this line and let us know if that fixes it.

ScrollView overlapping NavigationView bar
 
 
Q