Swift - Rotate gesture and rotation increments of 90 degrees
<p>I have a rotateView setup with a <code>UIRotationGestureRecognizer</code>. Works as intended, however I would like to only rotate in notches/increments of 90 degrees. The default behavior allows you to be very granular and precise with the rotation. I want it to be the opposite, of only 4 possible positions. </p>

<p>The code I have below is as close I could get, however the problem I am facing is the rotation only happens once, and only to one direction (rotates to the right, even if I 2-fingers rotate to the left).</p>

<p><strong>My code</strong></p>

<pre><code>func rotatedView(recognizer:UIRotationGestureRecognizer){
    let pi = CGFloat(M_PI)
    rotateView.transform = CGAffineTransformMakeRotation(pi/2)
    recognizer.rotation = 0
    if recognizer.state == UIGestureRecognizerState.Changed {
        print("rotation began")
    }
    else {
        print("rotation ended")
    }
}
</code></pre>

<p>How can I modify the above code to allow for 90 degree rotation increments in either direction based on gesture?</p>