In SwiftUI List
Appears to have a property called ListStyle
.
How can i change the style of the list
struct ListView : View {
After Xcode Beta 5 this approach is now deprecated; now Apple created a struct implementation for every style. So you should do like:
.listStyle(GroupedListStyle())
. Same approach is applied to other styles available.
Just do .listStyle(.grouped)
. For other list style use
.carousel
.default
.plain
.sidebar
Basically you are just passing ListStyle.grouped
to the method, but thanks to swift type inference you don't need to specify the struct.
Every static member work in this way.
StaticMember
means that there is a static member in the ListStyle
protocol. The declaration is this.
extension StaticMember where Base : ListStyle {
/// A `ListStyle` that implements the system default grouped `List`
/// interaction and appearance.
public static var grouped: GroupedListStyle.Member { get }
}