Check Mobile App
Read now

Gestures:- UIRotationGestureRecognizer

Save

A UIGestures is called when the user performs a long press. A motion that invokes an action as the drag-event sequence changes. A gesture that recognizes a motion and tracks the angle of the rotation.

UiKit have many gestures recognizer like:-

  1. UITapGestureRecognizer
  2. UIPinchGestureRecognizer
  3. UIRotationGestureRecognizer
  4. UISwipeGestureRecognizer
  5. UIPanGestureRecognizer
  6. UIScreenEdgePanGestureRecognizer
  7. UILongPressGestureRecognizer
  8. UIHoverGestureRecognizer

Now, we are going to know about UIRotationGestureRecognizer. UIRotationGestureRecognizer is a little tricky than other gesture recognizers.

Now, we are going to apply rotation gestures on UIView.

Let’s start

  1. Firstly open the Xcode and create a UIView with color put onto your storyboard.
  2. After that, create a outlet of a view in your ViewController file.
Create an outlet

Add UIRotationGestureRecognizer to UIView:

Let’s Create a method that is performing an action when the UIRotationGestureRecognizer detects rotation motion.

Now, set it to the gesture recognizer in viewDidLoad function.

Now build, run your project, and try any rotation motions to check the rotatedViewAct method is being called.

Detect States:

In the rotateViewAct method, we can check when the begin, changed, and ended with the gestures recognizer’s property called state.

Let’s run it and see this really detects motion states, for instance, when you begin rotation gesture you should see “rotation begin” when rotating see “rotation changing” and when ending rotating see “rotation end”.

Conclusion :

In Conclusion, Gesture Recognizer is easy and more simple when you used it in your application, they ultimately engage a level of user interaction.

Lastly, Please share your thoughts with us in the comment area.

iOS
. . .

Leave a Comment

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


Be the first to comment.

css.php

Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!

Deniel Kerr

Owner and Founder. Opencart

Talk to Sales
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home