Skip to content

SwiftUI: Rotation Gesture

With two fingers, you will be able to rotate a view. In order to so, the gesture provides you with an angle which you can use to rotate the view.

A gesture that recognizes a rotation motion and tracks the angle of the rotation.

Apple Documentation

In this tutorial, you’ll learn what is Rotation Gesture in SwiftUI. You’ll learn:

  • How to use Rotation Gesture.


To follow along this tutorial, you’ll need some basic knowledge in:

  • A basic familiarity with Swift.
  • At least Xcode 11

Rotation Gesture

You will be rotate a Tesla Model X based on your finger’s rotation angle. But in order to do that, you will need a variable to store the value.

Then you can use RotationGesture to get the degree and store the degree into the variable provided above. With that value, you can use it inside .rotationEffect.

As a result, you will see:

Where to go From Here

If you feel like you are ready to take on more challenges, feel free to check out some other tutorials that we have created:

Published inSwiftUI

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © DaddyCoding 2017-2020