Jos*_*ane 11 iphone animation rotation uiimageview
我想左右旋转UIImageView大约10度,但是有一个平滑的动画,而不是我看到的突然转弯:
player.transform = CGAffineTransformMakeRotation(angle)
Run Code Online (Sandbox Code Playgroud)
任何帮助表示感谢,谢谢.
Nig*_*pps 14
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.25]; // Set how long your animation goes for
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
player.transform = CGAffineTransformMakeRotation(angle); // if angle is in radians
// if you want to use degrees instead of radians add the following above your @implementation
// #define degreesToRadians(x)(x * M_PI / 180)
// and change the above code to: player.transform = CGAffineTransformMakeRotation(degreesToRadians(angle));
[UIView commitAnimations];
// The rotation code above will rotate your object to the angle and not rotate beyond that.
// If you want to rotate the object again but continue from the current angle, use this instead:
// player.transform = CGAffineTransformRotate(player.transform, degreesToRadians(angle));
Run Code Online (Sandbox Code Playgroud)
jer*_*jer 11
我使用这样的代码来实现类似的效果(虽然我将其旋转360度):
CABasicAnimation *rotate;
rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
rotate.fromValue = [NSNumber numberWithFloat:0];
rotate.toValue = [NSNumber numberWithFloat:deg2rad(10)];
rotate.duration = 0.25;
rotate.repeatCount = 1;
[self.view.layer addAnimation:rotate forKey:@"10"];
Run Code Online (Sandbox Code Playgroud)
我使用与此非常相似的代码来旋转图像视图.
| 归档时间: |
|
| 查看次数: |
16363 次 |
| 最近记录: |