Rotating a UIView by fixed(in any direction) angle using UIRotationGestureRecognizer?
Guyz...i'm stucked with a silly problem...
I can rotate my UIView using UIR开发者_如何学CotationGestureRecognizer but just want to rotate it with an fixed angle(for say 45 degree) in any direction considering a threshold value(recognizer.rotation).
Please help me...thanks in advance....
:)
This code snippet works for me
-(void)doAction:(UIRotationGestureRecognizer *)recognizer {
if ([recognizer state] == UIGestureRecognizerStateEnded){
float RotationinDegrees = recognizer.rotation * (180/M_PI);
NSLog(@"Rotation %f",RotationinDegrees);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.3];
if (RotationinDegrees>thresholdValue) {
self.transform = CGAffineTransformRotate([self transform], DEGREES_TO_RADIANS(desiredangle));
}
[UIView commitAnimations];
[recognizer setRotation:0];
}
}
精彩评论