我发现.listRowBackground(Color.Red.Blush)可以设置列表行列,但是在List中有一些空行仍然是白色的。当我在列表上滚动时,它还会显示一些白色区域。有人可以帮助解决这个问题吗?也非常感谢您告诉我如何使用SegmentedPickerStyle更改颜色。该视频显示了我的问题。 https://youtu.be/aEPw5hHBkFE 谢谢!
struct UserNotificationCellView: View {
@ObservedObject var userNotification: UserNotification
@ObservedObject var userNotifications: UserNotifications
var body: some View {
{
......
}
.padding(.horizontal,20)
.cornerRadius(14)
.listRowBackground(Color.Red.Blush)
// .background(Color.Red.Blush)
}
}
下面是我的列表代码
List {
ForEach(userNotifications1.userNotificationsArray, id: \.notifyId) { (userNotification) in
UserNotificationCellView(userNotification: userNotification,userNotifications: self.userNotifications1)
// .listRowBackground(Color.Red.Blush)
}.colorMultiply(Color.Red.Blush)
Spacer()
}.environment(\.defaultMinListRowHeight, 80)
答案 0 :(得分:1)
我建议在您的AppDelegate类中添加全局样式。在这里,您可以通过外观更改SwiftUI当前无法访问的类属性。
UITableView.appearance().backgroundColor = .clear
UISegmentedControl.appearance().....
您可以在此处更改列表背景颜色和所需的任何分段控件属性。
对于空白单元格,您可以尝试添加空白页脚
List {
Section(footer: self.footer) {
ForEach(userNotifications1.userNotificationsArray, id: \.notifyId) { (userNotification) in
UserNotificationCellView(userNotification: userNotification,userNotifications: self.userNotifications1)
// .listRowBackground(Color.Red.Blush)
}.colorMultiply(Color.Red.Blush)
}
}.environment(\.defaultMinListRowHeight, 80)