SwiftUI 禁用列表边框 iOS 14
SwiftUI disable list border iOS 14
我发现 SwiftUI 中的列表 iOS 如果视图包含 navigationView,14 将具有类似边框的内容。是否有任何解决方案可以禁用边框?因为边框破坏了我的应用程序的设计。
这是代码中没有包含 NavigationView 的代码。
struct ContentView: View {
@State var isPresent = false
var body: some View {
let first = Restaurant(name: "Joe's Original")
let second = Restaurant(name: "The Real Joe's Original")
let third = Restaurant(name: "Original Joe's")
let restaurants = [first, second, third]
VStack{
List(restaurants) { restaurant in
Text(restaurant.name)
}
}
}
}
}
这是包含 NavigationView 的代码
struct ContentView: View {
@State var isPresent = false
var body: some View {
let first = Restaurant(name: "Joe's Original")
let second = Restaurant(name: "The Real Joe's Original")
let third = Restaurant(name: "Original Joe's")
let restaurants = [first, second, third]
NavigationView{
VStack{
List(restaurants) { restaurant in
Text(restaurant.name)
}
}
}
}
}
我想要的设计是第一张照片。我不知道如何禁用添加到列表 iOS14 中的边框。有什么建议吗?
尝试明确使用普通列表样式(我假设他们现在默认使用插入列表样式)
NavigationView{
VStack{
List(restaurants) { restaurant in
Text(restaurant.name)
}
.listStyle(PlainListStyle()) // << here !!
}
}
我发现 SwiftUI 中的列表 iOS 如果视图包含 navigationView,14 将具有类似边框的内容。是否有任何解决方案可以禁用边框?因为边框破坏了我的应用程序的设计。
这是代码中没有包含 NavigationView 的代码。
struct ContentView: View {
@State var isPresent = false
var body: some View {
let first = Restaurant(name: "Joe's Original")
let second = Restaurant(name: "The Real Joe's Original")
let third = Restaurant(name: "Original Joe's")
let restaurants = [first, second, third]
VStack{
List(restaurants) { restaurant in
Text(restaurant.name)
}
}
}
}
}
这是包含 NavigationView 的代码
struct ContentView: View {
@State var isPresent = false
var body: some View {
let first = Restaurant(name: "Joe's Original")
let second = Restaurant(name: "The Real Joe's Original")
let third = Restaurant(name: "Original Joe's")
let restaurants = [first, second, third]
NavigationView{
VStack{
List(restaurants) { restaurant in
Text(restaurant.name)
}
}
}
}
}
我想要的设计是第一张照片。我不知道如何禁用添加到列表 iOS14 中的边框。有什么建议吗?
尝试明确使用普通列表样式(我假设他们现在默认使用插入列表样式)
NavigationView{
VStack{
List(restaurants) { restaurant in
Text(restaurant.name)
}
.listStyle(PlainListStyle()) // << here !!
}
}