Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created February 21, 2023 20:03
Show Gist options
  • Save sturdysturge/0179575a64e8fcafcd5d5f8474693adb to your computer and use it in GitHub Desktop.
Save sturdysturge/0179575a64e8fcafcd5d5f8474693adb to your computer and use it in GitHub Desktop.
import SwiftUI
@available(iOS 16.0, *)
struct ContentView: View {
var body: some View {
VStack {
List {
Section("Separators") {
ForEach(0..<10) { index in
Text("\(index) Separate")
}
// Implicit .listRowSeparator(.automatic) is
// .listRowSeparator(.visible) on iOS
}
Section("No Separators") {
ForEach(0..<10) { index in
Text("\(index) Not Separate")
}
.listRowSeparator(.hidden)
}
Section("Every Other Separator") {
ForEach(0..<10) { index in
let indexIsEven = index % 2 == 0
Text("\(index) \(indexIsEven ? "Hidden" : "Visible")")
.listRowSeparator(indexIsEven ? .hidden : .visible)
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment