SwiftUI: Navigation Title Stuck in Place (Scroll Animation Broken) for List in NavigationView
Asked Answered
S

1

8

I have created a SwiftUI List wrapped in a NavigationView. The title for the list is set in the default way and appears fine: .navigationBarTitle("My Title"). The problem is the scrolling behavior is broken.

That is, when scrolling the list, the large title should disappear to make way for the navigation bar to appear with the small title. However, the large title is just stuck in place and does not move while the list scrolls behind it in a glitchy looking manner.

Stutman answered 17/12, 2019 at 1:29 Comment(0)
S
19

Turns out, setting the background of the List breaks the scrolling behavior. That is, removing .background(Color.red) on the List restored the scrolling behavior to normal.

Stutman answered 17/12, 2019 at 1:29 Comment(6)
This happens to me too, but I don't have a background on the List. I only have .listStyle(GroupedListStyle()). Removing it doesn't resolve the issue.Durwin
@Durwin Is your list wrapped in a stack or is it the root view in the navigation view? For example, if it's in a VStack, this seems to happen if it is not the top item in the stack. If something comes before it, in other words, I believe this happens. Try experimenting with removing an containing views and/or rearranging them to see what you get.Stutman
I ran into this issue with my iOS 14 compiled app running on iOS 15 Beta 2, removing the .background modifier worked! There was no issue with an iOS 14 compiled app running on iOS 14, nor iOS 15 compiled app running on iOS 15. I've submitted a radar.Agro
@Stutman I have the issue because I have a custom searchBar view stacked on top of the List, contained within a VStack. There's a new searchable method in iOS 15 that removes this bug, but I still need to support iOS 14 for the foreseeable future. Any idea how to solve this in iOS 14 and SwiftUI 2?Endlong
@Stutman what details do you have on the searchable method please? Experiencing the same issue - thanksHogweed
How can we design an app with custom backgrounds, anyway? As soon as I set a background, even at inner levels, the navigationtitle stops collpasing. Totally the expected behaviour, of course, thanks Apple.Erine

© 2022 - 2024 — McMap. All rights reserved.