07 - Touches & Gestures Recap
We use touches and gestures to produce a variety of user interactions with almost any kind of outlet. They help us with matters such detecting a tap on an item or when we pinch two taps and want to rotate an object.
Touches Began & Ended
Touches began and ended are the most basic touch events. We use them to trigger the moment any number of touches have landed or left the screen.
Touches Moved
Touches moved method is the next in line of the touches actions. Similar to both touches began and ended, it returns both the current location and the previous location of the touch in the view.
Function Overloads
We use function overloads to call the same method but with different parameters or arguments. Function overloads help us add functionality to our code based on what we expect to write in the code. Read more on function overloads in:
https://www.programiz.com/swift-programming/function-overloading
UI Gestures
We use UI Gesture Recognizer in the interface builder to add gestures such as pan, long press or pinch to our views. Gestures can be used either as a point to return a value such as the amount of rotation or to trigger a segue. We can add gesture recognizer in both the interface builder and the code. In order to add Gesture Recognizers in the code, we have to add them to a view.
CG Transform
CG Transforms are a part of core graphics that help us translate, scale, rotate or skew an outlet.
Custom UI Gestures
To use a GestureRecognizer we should sub-class it.