[英]How can I make a SwiftUI List row background color extend the full width, including outside of the safe area
[英]How can I set background color of SwiftUI List Header in safe area in Landscape?
我正在尝试为横向列表标题设置安全区域的背景,但我似乎无法更改默认的深灰色。 我可以为行更改它,但不能为标题更改。 我不想使用 GroupedListStyle。 只想要一个普通列表但要更改安全区域背景:
List {
Section(header:
HStack {
SearchBar()
}
.padding(.horizontal)
.background(Color.white)
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
) {
...
}
}
我曾尝试使用 .edgesIgnoringSafeArea 设置背景并使用 ZStack 方法,但深灰色来自实际标题,无论如何我找不到在横向覆盖它。
明确地应用列表样式以针对所有模式修复它(使用 Xcode 13 / iOS 15 测试)
List {
// header here
// content here
}
.listStyle(.plain) // << here !!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.