Created
April 16, 2024 04:16
-
-
Save huynguyencong/0364839959b9d086558ec80b10d0ac52 to your computer and use it in GitHub Desktop.
A way to put an image in a parent view, filled in an area with a specific aspect ratio
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
VStack { | |
Color.clear | |
.aspectRatio(16/9, contentMode: .fit) | |
.overlay { | |
Image(systemName: "icon") | |
.resizable() | |
.scaledToFill() | |
} | |
.clipped() | |
Text("Title") | |
Spacer() | |
} | |
.frame(width: 200, height: 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment