Skip to content

Instantly share code, notes, and snippets.

@SoundBlaster
Last active November 10, 2021 21:45
Show Gist options
  • Save SoundBlaster/34e9be46f486cb4d222f7caf55d649a2 to your computer and use it in GitHub Desktop.
Save SoundBlaster/34e9be46f486cb4d222f7caf55d649a2 to your computer and use it in GitHub Desktop.
Empty View as last item in SwiftUI List
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
ZStack {
List {
ForEach(1..<20) { idx in
if idx == 19 {
Rectangle()
.fill(.clear)
.frame(width: .infinity, height: 44)
.listRowSeparator(.hidden)
} else {
Text("Item")
}
}
}
.listStyle(.plain)
VStack {
Spacer()
Rectangle()
.fill(.red)
.frame(width: .infinity, height: 44)
}
}
.navigationTitle("Main page")
}
}
}
import PlaygroundSupport
PlaygroundPage.current.liveView = UIHostingController(
rootView: ContentView()
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment