ali*_*ego 10 ios swift swiftui swiftui-list
我在 SwiftUI 中有一个 InsetGroupedListStyle 列表,并注意到 iOS 15 中添加了额外的顶部填充。我如何控制或删除它?
List {
Section(header: Text("Header")) {
// some content
}
}
.listStyle(InsetGroupedListStyle())
Run Code Online (Sandbox Code Playgroud)
这是 iOS 14:
和 iOS 15:
要解决此问题,您可以使用headerProminence
Section("Header") {
// some content
}
.headerProminence(.increased)
Run Code Online (Sandbox Code Playgroud)
修复表视图的问题
if #available(iOS 15.0, *)
UITableView.appearance().sectionHeaderTopPadding = 0;
Run Code Online (Sandbox Code Playgroud)
更新:我想我找到了这个特定案例的解决方案:
tableView.tableHeaderView = .init(frame: .init(x: 0, y: 0, width: 0, height: CGFloat.leastNonzeroMagnitude))
Run Code Online (Sandbox Code Playgroud)
我遇到了类似的令人沮丧的问题,这样做对我有帮助
List {
Section(header: Text("Header")) {
// some content
}
}
.listStyle(PlainListStyle())
Run Code Online (Sandbox Code Playgroud)
请注意,这改变了我的标题的颜色
| 归档时间: |
|
| 查看次数: |
7006 次 |
| 最近记录: |