Create an Inset Grouped List in SwiftUI for macOS
When you have an iOS app, especially when it displays information, you maybe use InsetGroupedListStyle
on your List
. This looks any like this:
But there is a problem, when you want to display this view on macOS. InsetGroupedListStyle
is unavailable for native apps (It’s available for Mac Catalyst though). And when you use alternative list styles for the list, it looks like this:
It doesn’t look that bad, but it is not consistent with the iOS app design.
Creating the view extension
There isn’t a way to create a custom ListStyle
. So we create a view extension
, that we can use on the sections.