Created
June 20, 2020 07:19
-
-
Save gahntpo/9ec4531c7d4a01b15eac3ee62945bf0a to your computer and use it in GitHub Desktop.
positioning a view inside a given frame with .position() and .offset()
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
ZStack { | |
Rectangle() | |
.fill(Color.green) | |
.position(x: 100, y: 100) | |
.frame(width: size, height: size) | |
.border(Color.green) | |
Rectangle() | |
.fill(Color.red) | |
.offset(CGSize(width: 100, height: 100)) | |
.frame(width: size, height: size) | |
.border(Color.red) | |
}.frame(width: 150, height: 150, alignment: .topLeading) | |
.border(Color.gray) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment