我在 SwiftUI 中创建了一个列表。我想更改颜色或删除分隔符,因为在 UIKit 中,我们可以轻松更改 TableView 中分隔符的颜色。
下面是 SwiftUI 中列表的代码和 UI(图片)
@State private var users = ["Paul", "Taylor", "Adele"]
var body: some View {
List(){
ForEach(users, id: \.self) { user in
HStack{
Image("helmet").resizable().frame(width: 40, height: 40, alignment: .leading)
VStack(alignment : .leading){
Text(user).font(.custom("SFProText-Semibold", size: 14))
Text("Blu Connect").font(.custom("SFProText-Semibold.ttf", size: 11))
}
}
}
.onDelete(perform: delete)
}
}