1

As you know there are so many changes on iOS 14, especially for lists.

I found this modifier for hiding separators in lists but .listStyle(SidebarListStyle()) modifier is not working as I expected.

List{
  MessageDetail(messages: self.$viewModel.messages)
}.noSeparators()
 .modifier(DismissingKeyboard())
 .scaleEffect(x: 1, y: -1, anchor: .center)
 .offset(y:-5)

Extension:

extension List {
    @ViewBuilder func noSeparators() -> some View {
        #if swift(>=5.3) // Xcode 12
        if #available(iOS 14.0, *) { // iOS 14
            self
            .listStyle(SidebarListStyle())
        } else { // iOS 13
            self
            .listStyle(PlainListStyle())
            .onAppear {
                UITableView.appearance().tableFooterView = UIView()
                UITableView.appearance().separatorStyle = .none
            }
            .onDisappear {
                UITableView.appearance().separatorStyle = .singleLine
            }
        }
        #else // Xcode 11.5
        self
        .listStyle(PlainListStyle())
        .onAppear {
            UITableView.appearance().tableFooterView = UIView()
            UITableView.appearance().separatorStyle = .none
        }
        .onDisappear {
            UITableView.appearance().separatorStyle = .singleLine
        }
        #endif
    }
}

and ugly result :

Screenshot

  • This style `SidebarListStyle()` is definitely not for hiding separators. Just in case. – Asperi Sep 19 '20 at 12:57
  • @Asperi I researched many solutions for hiding separators, almost everyone suggested SidebarListStyle() but not working yeah. I'm still searching a working solution. – Halil İbrahim YÜCE Sep 19 '20 at 13:11
  • Does this answer your question https://stackoverflow.com/a/62598818/12299030? – Asperi Sep 19 '20 at 13:15
  • @Asperi yeah I tried it, it worked but still there is a separator at the bottom of list. I thought maybe I can find a better solution. – Halil İbrahim YÜCE Sep 19 '20 at 13:18
  • I don't have any more *separator at the bottom of list*. Xcode 12GB / iOS14GM. – Asperi Sep 19 '20 at 13:51
  • @Asperi I don't know why but I have, interesting problem. I'm using Xcode 12 and iOS 14 latest versions too. – Halil İbrahim YÜCE Sep 19 '20 at 13:56
  • On 14.4 I find .listStyle(SidebarListStyle()) working as expected. @Asperi, just curious, why "definitely not for hiding separators"? Is there some ancillary problem with it I haven't encountered (yet)? – Mark Phillips Feb 12 '21 at 06:41

0 Answers0