How to use Image in SwiftUI
SwiftUI’s Image allows you to showcase different variations of design in your app
Published in
3 min readMar 19, 2020
In this tutorial, you’ll learn what SwiftUI Image is. You’ll learn:
- How to resize your image
- How to mask your image
- The luminance to alpha effect
Prerequisites
To follow this tutorial, you’ll need:
- Basic familiarity with Swift
- at least Xcode 11
Resizeable
To modify the size of the image, you have to almost always include resizeable()
.
Image("tesla")
.resizable()
.scaledToFill()
.frame(width: 200, height: 200)
Mask
You can use mask the image by adding a layer on top of it.
.mask(RoundedRectangle(cornerRadius: 4.0))
.mask(Circle())