Skip to content

Workaround to hide/modify List separators in SwiftUI iOS13 and iOS14

License

Notifications You must be signed in to change notification settings

SchmidtyApps/SwiftUIListSeparator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftUI List Separator

View extension to hide/modify List separators in SwiftUI iOS13 and iOS14.

Swift Version License Platform PRs Welcome

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.

Requirements

  • iOS 13.0+
  • Xcode 11.0+

Installation

Manually

  1. Download and drop List+Separator.swift in your project.
  2. Congratulations!

Usage example

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)

Contribute

We would love you for the contribution to SwiftUIListSeparator, check the LICENSE file for more info.

Meta

Michael Schmidt – @FindMyClassKineticSparks@gmail.com

Distributed under the MIT license. See LICENSE for more information.

https://github.com/SchmidtyApps

About

Workaround to hide/modify List separators in SwiftUI iOS13 and iOS14

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages