Iphone 旋转带有按钮的UIView
我正在尝试旋转一个UIview,它在左上角有一个UIButton,动作如下:Iphone 旋转带有按钮的UIView,iphone,uiview,rotation,imageview,Iphone,Uiview,Rotation,Imageview,我正在尝试旋转一个UIview,它在左上角有一个UIButton,动作如下: NSLog@“你好” 现在我将UIView旋转180°,按钮现在位于右下角。但只有当我按下左上角的按钮时,按钮才会启动它的动作。。。这就像按钮的位置改变了,但它的动作和旋转前一样 我使用CAKeyframeAnimation旋转视图 CAKeyframeAnimation *rotationAnimation; rotationAnimation = [CAKeyframeAnimation animationWith
NSLog@“你好”代码>
现在我将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"];
使用CGAFFINETRANSFORM进行旋转
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
CGAffineTransform transform=CGAffineTransformMakeRotation(3.14159265);
yourView.transform=transform;
[UIView commitAnimations];
将旋转动画代码放入我尝试添加的详细信息中,但我无法在按钮移动时按下按钮。