SwiftUI 4 — Add Scroll Background
A tiny and long awaited modifier for SwiftUI 4 in iOS 16 beta 3
Apple has just released a new beta version of his iOS 16 with a little and long awaited modifier…
The scrollContentBackground
modifier is able to do a small thing that was really really missed since the first version of SwiftUI: the ability to add a background color to a List
view. Without this modifier you had to override the init of the table and write smelly code in UIKit… it was not a very pleasant approach and because of this, I admit it, I used lists as less as possible my own apps.
Using the modifier is super simple, just add it after the List
view and the magic is done:
So scrollContentBackground
modifier will set the style to use for the background. If the value is nil
, the system will use the default style to fill the background.
Please note that this modifier is available only in iOS 16 Beta 3 and forth.
You can also pass the style .hidden
to make the background clear and use the standard one in your screen: