我已经尝试了许多方法来使这里的白色背景清晰。似乎没有任何效果。
struct OverlayChatView: View {
var body: some View {
ZStack {
Color.clear
List(0 ..< 5) { item in
ChatMessageCell()
}
.listRowBackground(Color.clear)
.background(Color.clear)
}
}
}
struct ChatMessageCell: View {
var body: some View {
HStack {
Image(systemName: "person.crop.circle")
.aspectRatio(1.0, contentMode: .fill)
Text("This is a chat message of certain length to try to force a wrap in the preview.")
}
}
}
struct OverlayChatView_Previews: PreviewProvider {
static var previews: some View {
ZStack {
Color.blue
.ignoresSafeArea()
OverlayChatView()
.frame(maxWidth: 300.0, maxHeight: 300.0)
.background(Color.clear)
}
}
}
很多人似乎都遇到了这个问题,有些人用非首发解决了这个问题:
.onAppear {
UITableView.appearance().backgroundColor = UIColor.clear
UITableViewCell.appearance().backgroundColor = UIColor.clear
}
我可以将单个列表项单元格设置为特定的不透明背景颜色。我什至无法将OverlayChatView
或设置List
为纯色,更不用说清除了。
iOS 14(模拟器,不是设备)