I have a SwiftUI List with a background. In iOS 13 I was successful in making the List transparent, so that the background will show through, by setting UITableView attributes in an init(). With iOS 14 the behavior has changed. A code snippet below shows the init settings. I have confirmed that this extracted snippet works as expected (background showing through the list) in iOS 13, but in iOS 14 the populated rows in the List block the background as if the background was white and not clear.
Has anyone else seen this? Is there another way to make the List transparent that will work with both iOS 13 and 14?
struct RecorderList: View {
init(){
UITableView.appearance().backgroundColor = .clear
UITableViewCell.appearance().backgroundColor = .clear
UINavigationBar.appearance().largeTitleTextAttributes = [
.foregroundColor: UIColor.purple,
.font: UIFont(name:"Papyrus", size: 40) ?? UIFont.systemFont(ofSize:40)]
}
var body: some View {
NavigationView {
ZStack (alignment: .top){
Image("background")
.resizable()
.scaledToFit()
List {
Text("One")
.font(.title)
.background(Color.clear)
Text("Two")
.font(.title)
.background(Color.clear)
Text("Three")
.font(.title)
.background(Color.clear)
Text("Four")
.font(.title)
.background(Color.clear)
Text("Five")
.font(.title)
.background(Color.clear)
}
}
.navigationBarTitle("Recorders")
}
}
}
UITableViewCell.appearance().backgroundColor = ...
has no effect in iOS 14 - which I would call it a bug. Still same behaviour in Simulator iOS 14.5.listRowBackground(..)
doesn't work either. – Disastrous