Skip to content

Instantly share code, notes, and snippets.

@gahntpo
Created June 20, 2020 07:19
Show Gist options
  • Save gahntpo/9ec4531c7d4a01b15eac3ee62945bf0a to your computer and use it in GitHub Desktop.
Save gahntpo/9ec4531c7d4a01b15eac3ee62945bf0a to your computer and use it in GitHub Desktop.
positioning a view inside a given frame with .position() and .offset()
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