Last active
February 28, 2024 14:43
-
-
Save rubencodes/2335417b432d8c348028c4798af02d73 to your computer and use it in GitHub Desktop.
SwiftUI Spacing Demo
This file contains 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
@available(iOS 16.0, *) | |
struct SpacingDemo_Previews: PreviewProvider { | |
static var previews: some View { | |
NavigationStack { | |
Form { | |
Group { | |
Section { | |
HStack { | |
Spacer() | |
Rectangle().fill(.blue) | |
Spacer() | |
} | |
.background(.red) | |
} header: { | |
Text("MinLength Default, Stack Spacing Default") | |
} | |
Section { | |
HStack { | |
Spacer(minLength: 0) | |
Rectangle().fill(.blue) | |
Spacer(minLength: 0) | |
} | |
.background(.red) | |
} header: { | |
Text("MinLength Zero, Stack Spacing Default") | |
} | |
Section { | |
HStack(spacing: 8) { | |
Spacer(minLength: 0) | |
Rectangle().fill(.blue) | |
Spacer(minLength: 0) | |
} | |
.background(.red) | |
} header: { | |
Text("MinLength Zero, Stack Spacing 8") | |
} | |
Section { | |
HStack(spacing: 0) { | |
Spacer(minLength: 0) | |
Rectangle().fill(.blue) | |
Spacer(minLength: 0) | |
} | |
.background(.red) | |
} header: { | |
Text("MinLength Zero, Stack Spacing Zero") | |
} | |
Section { | |
HStack { | |
Text("Hi").background(.green) | |
Rectangle().fill(.blue) | |
Text("Hi").background(.green) | |
} | |
.background(.red) | |
} header: { | |
Text("Text, with Stack Spacing Default") | |
} | |
} | |
.listRowBackground(Color.clear) | |
.listRowSpacing(.zero) | |
} | |
.navigationTitle("Spacing Demo") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment