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.sidebarBasically 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 }
}
in Xcode 11.2.1, Right answer is in the below.
.listStyle(GroupedListStyle())
Conforming Types ->
CarouselListStyle
DefaultListStyle
GroupedListStyle
PlainListStyle
SidebarListStyle
ref:https://developer.apple.com/documentation/swiftui/liststyle
As of Xcode 11 beta 5, Apple requires the following, as briefly outlined here:
.listStyle(GroupedListStyle())
The following is breakdown on the various styles and where they can be used between iOS and watchOS, along with when they were introduced.
Introduced with iOS 13 and watchOS 6:
PlainListStyle
ListStyle
DefaultListStyle
Introduced with iOS 13:
GroupedListStyleIntroduced with iOS 14:
InsetGroupedListStyleInsetListStyleSidebarListStyleSome answers to this question also include styles that are watchOS specific, but are not clearly marked as such, despite the question being tagged iOS. For completeness...
Introduced with watchOS 6:
CarouselListStyleIntroduced with watchOS 7:
EllipticalListStyle