SwiftUI:如何摆脱列表中的顶部和底部分隔符
SwiftUI: how to get rid of top and bottom separators on lists
我在 SwiftUI 中使用列表,注意到当我只有一行时,分隔符仍然出现在顶部和底部:
同样,对于多行列表,这些分隔符仍然出现在顶部和底部。如何删除列表最顶部和最底部的分隔符,同时保留中间行之间的分隔符?
您可以使用修饰符隐藏分隔符 (iOS 15+)
List {
ForEach(garage.cars) { car in
Text(car.model)
.listRowSeparator(.hidden) // << this !!
}
}
我在 SwiftUI 中使用列表,注意到当我只有一行时,分隔符仍然出现在顶部和底部:
同样,对于多行列表,这些分隔符仍然出现在顶部和底部。如何删除列表最顶部和最底部的分隔符,同时保留中间行之间的分隔符?
您可以使用修饰符隐藏分隔符 (iOS 15+)
List {
ForEach(garage.cars) { car in
Text(car.model)
.listRowSeparator(.hidden) // << this !!
}
}