2012-09-11 22 views
1

我试图转动它在左上角用行动一个UIButton一个UIView:旋转的UIView与按钮它

[email protected]"hello";

现在我旋转的UIView 180°和按钮现在在右下角。但是只有当我按下左上角时按钮才会触发它的动作...所以它像按钮的位置已经改变,但它的动作停留在旋转之前的相同位置?

我使用CAKeyframeAnimation旋转视图。

CAKeyframeAnimation *rotationAnimation; 
rotationAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"]; 

rotationAnimation.values = [NSArray arrayWithObjects: 
          [NSNumber numberWithFloat:0.0 * M_PI], 
          [NSNumber numberWithFloat:0.75 * M_PI], 
          [NSNumber numberWithFloat:1.5 * M_PI], 
          [NSNumber numberWithFloat:2.0 * M_PI], nil]; 
rotationAnimation.calculationMode = kCAAnimationPaced; 


rotationAnimation.removedOnCompletion = NO; 
rotationAnimation.fillMode = kCAFillModeForwards; 

rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; 
rotationAnimation.duration = 10.0; 

CALayer *layer = [rotateView layer]; 
[layer addAnimation:rotationAnimation forKey:@"rotationAnimation"]; 
+0

把你的旋转动画代码的细节 –

回答

0

使用CGAFFINETRANSFORM为rotaion

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:0.2]; 
    CGAffineTransform transform=CGAffineTransformMakeRotation(3.14159265); 
    yourView.transform=transform; 
[UIView commitAnimations]; 
+0

是的,我triedd,但我不能按下按钮,而其移动。 – Franhu