[英]SwiftUI: Navigation Title Stuck in Place (Scroll Animation Broken) for List in NavigationView
I have created a SwiftUI List
wrapped in a NavigationView
.我创建了一个包含在
NavigationView
的 SwiftUI List
。 The title for the list is set in the default way and appears fine: .navigationBarTitle("My Title")
.列表的标题以默认方式设置并且显示正常:
.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.
然而,大标题只是卡在原地,当列表以一种看起来有问题的方式在它后面滚动时不会移动。
Turns out, setting the background of the List
breaks the scrolling behavior.事实证明,设置
List
的背景会破坏滚动行为。 That is, removing .background(Color.red)
on the List
restored the scrolling behavior to normal.也就是说,删除
List
上的.background(Color.red)
使滚动行为恢复正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.