Moj*_*ini 13
今年 Apple 推出了一种新的修饰符.listRowSeparator,可用于设置分隔符的样式。你可以通过.hidden隐藏它:
List {
ForEach(items, id:\.self) {
Text("Row \($0)")
.listRowSeparator(.hidden)
}
}
Run Code Online (Sandbox Code Playgroud)
在 iOS 14 中,您可以考虑使用LazyVStack代替列表:
ScrollView {
LazyVStack {
ForEach((1...100), id: \.self) {
Text("Placeholder \($0)")
}
}
}
Run Code Online (Sandbox Code Playgroud)
请记住,这LazyVStack是惰性的,并且不会一直渲染所有行。因此它们的性能非常好,并且是 Apple 自己在 WWDC 2020 中推荐的。
iOSUITableView背后有一个SwiftUI List。所以要删除
你需要一个tableFooterViewand 来删除
你需要separatorStyle成为.none
init() {
// To remove only extra separators below the list:
UITableView.appearance().tableFooterView = UIView()
// To remove all separators including the actual ones:
UITableView.appearance().separatorStyle = .none
}
var body: some View {
List {
Text("Item 1")
Text("Item 2")
Text("Item 3")
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5058 次 |
| 最近记录: |