How to use Scale Effect in SwiftUI
Pinch to make content larger or smaller
The scale effect is used to make content either larger or smaller. You’ll be able to find so much more you can do with the scale effect, and you’ll be just as amazed as I was when I found out what it can do.
“Scales this view’s rendered output by the given amount in both the horizontal and vertical directions, relative to an anchor point.”— Apple Documentation
In this tutorial, you’ll learn what the scale effect is in SwiftUI. You’ll learn:
- How to use the scale effect.
Prerequisites
To follow along with this tutorial, you’ll need some basic knowledge in:
- Swift
- At least Xcode 11
Scale Effect
You can choose to scale either text or an image. In this example, you will scale an image with the following code:
.scaleEffect(1.0)
The first image is an example of a scale effect of 1.0, and the second image is an example of a scale effect of 3.0.