In UIKit I can easily set scrollable background pattern for UITableView
like this:
tableView.backgroundColor = .init(patternImage: .init(named: "background")!)
Background image in such case is infinitely tiled and is scrollable along with scroll content.
If I try to do the same in SwiftUI:
List {
...
}
.background(
Color(
UIColor(patternImage: .init(named: "background")!)
)
)
.scrollContentBackground(.hidden)
background isn't set at all. Similar problem described here: SwiftUI can't create Color by UIColor(patternImage:).
If I try to set background image:
List {
...
}
.background(
Image("background").resizable(resizingMode: .tile)
)
.scrollContentBackground(.hidden)
it is displayed and tiled, but not scrollable.
How to make for SwiftUI List
the same behaviour as in UIKit?
backgroundColor
the same way. There is currently no SwiftUI API for this. With aScrollView
you can at least put aRectangle
as large as the scrollable content, filled withImagePaint
, and that will scroll, but not withList
.