2012-09-11 59 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