Last active
November 10, 2021 21:45
-
-
Save SoundBlaster/34e9be46f486cb4d222f7caf55d649a2 to your computer and use it in GitHub Desktop.
Empty View as last item in SwiftUI List
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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