Guyz ......我被一个愚蠢的问题困扰了......
我可以使用UIRotationGestureRecognizer旋转我的UIView,但只想在任意方向上以固定角度(例如45度)旋转它,考虑阈值(recognizer.rotation)。
请帮助我......提前致谢....
:)
答案 0 :(得分:0)
此代码段适用于我
-(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];
}
}