Last active
March 9, 2021 02:02
-
-
Save paulhimes/06b3938181da1d9a001f1b754ab80ad3 to your computer and use it in GitHub Desktop.
OnLayout Tutorial 01
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
struct MainView: View { | |
var body: some View { | |
ScrollView { | |
HStack { | |
Spacer() | |
Text("ScrollView Content") | |
.multilineTextAlignment(.center) | |
.foregroundColor(.white) | |
.background(Color.blue.brightness(0.2)) | |
Spacer() | |
} | |
} | |
.background(Color.blue) | |
.overlay( | |
TitleBar(), | |
alignment: .top | |
) | |
.edgesIgnoringSafeArea(.all) | |
} | |
} | |
struct TitleBar : View { | |
var body: some View { | |
HStack { | |
Text("Title") | |
.frame(alignment: .center) | |
.foregroundColor(.white) | |
Spacer() | |
} | |
.padding( | |
EdgeInsets( | |
top: 50, | |
leading: 16, | |
bottom: 16, | |
trailing: 16 | |
) | |
) | |
.background(Color.red.opacity(0.5)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment