View extension to hide/modify List separators in SwiftUI iOS13 and iOS14.
SwiftUI List lacks the customizations necessary to hide/modify row separator lines. There are known workarounds with setting appearance for UITableView but many times this sets it for all UITableViews in the app and this workaround has also stopped working in iOS14. This project allows full customization of the separators on List and has been tested and works in both iOS13 and iOS14 when compiled with either Xcode 11 or Xcode 12.
- iOS 13.0+
- Xcode 11.0+
- Download and drop
List+Separator.swift
in your project. - Congratulations!
Show the standard single divider line (Note: this is equivalent to the sytem default so omitting is the same thing)
List { <content> }
.separator(style: .singleLine)
Hide separators on the List
List { <content> }
.separator(style: .none)
Show a single divider line with configurable color and insets
List { <content> }
.separator(style: .singleLine, color: .red, inset: EdgeInsets(top: 0, leading: 50, bottom: 0, trailing: 20)
Show a single divider line and hide the separator on empty rows in the footer
List { <content> }
.separator(style: .singleLine, hideOnEmptyRows: true)
We would love you for the contribution to SwiftUIListSeparator, check the LICENSE
file for more info.
Michael Schmidt – @FindMyClass – KineticSparks@gmail.com
Distributed under the MIT license. See LICENSE
for more information.