[英]How to remove blank space on top of List in SwiftUI
That space is associated with the NavigationView that your List is in - each view within the "stack" of the navigation's displayable views can set its own title that would then get displayed in that spot.该空间与您的列表所在的 NavigationView 相关联 - 导航可显示视图的“堆栈”中的每个视图都可以设置自己的标题,然后将显示在该位置。
If you're going to keep that space unused, you can mitigate by forcing the navigation title to be in inline mode.如果您要保持该空间未使用,您可以通过强制导航标题处于内联模式来缓解。 This is what you see when you scroll down a list and the big title shrinks and moves up into the toolbar space, between the leading and trailing toolbar items.
当您向下滚动列表并且大标题缩小并向上移动到工具栏空间中,在前导和尾随工具栏项之间,这是您所看到的。
To do this, add the .navigationBarDisplayMode
modifier to your list:为此,请将
.navigationBarDisplayMode
修饰符添加到您的列表中:
// within a NavigationView context
List {
// ...
}
.navigationBarTitleDisplayMode(.inline)
List {
Text("Space1 ")
}
.listStyle(PlainListStyle())
try this...尝试这个...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.