Reputation: 81
If I add a Pan Gesture Recognizer to the view and put down this code
recognizer.view.center.x > view.bounds.size.width
It is claimed that it can check whether it has passed half of the view yet.
What is the meaning of recognizer.view.center.x
?
Upvotes: 0
Views: 61
Reputation: 31
recognizer.view
returns the view that the pan gesture recognizer is attached to (the view which you added the recognizer to), and recognizer.view.center.x
returns the x-axis value of the centre of the view (essentially half of the width).
As far as I can understand, recognizer.view.center.x > view.bounds.size.width
will never be true because half of the width will never be larger than the width itself.
I assume you are trying to find whether if the point of touch has passed the middle of the view on the x-axis, try the following:
[recognizer locationInView:view].x > view.center.x
Similarly, if you want to find out if it has passed below the middle of the y-axis:
[recognizer locationInView:view].y > view.center.y
Upvotes: 2
Reputation: 318824
Follow the values.
recognizer
is the pan gesture.view
is the view the recognizer has been assigned to.center
is the view's center pointx
is the center's x coordinate.All of this can be seen by reading the reference documentation for each class. UIPanGestureRecognizer
extends UIGestureRecognizer
which is where you will find details about the view
property. Simply drill down from there.
Upvotes: 1