我正在试图扭曲对象卡,这是我正在做的UIView:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:DEPLACEMENT_ANIMATION_DUREE_SECONDES_DROITE];
scene.carte17.layer.position = positionInit;
if (scene.carte17.angleCarte == 15.f) {
scene.carte17.transform = CGAffineTransformRotate(scene.carte17.transform, degreesToRadians(30));
scene.carte17.angleCarte = 45.f;
}
[UIView commitAnimations];
它正在发挥作用!我的卡倾斜到30°,这很好。我正在玩setAnimationDuration来控制速度。
我想使用CoreAnimation和kCAMediaTimingFunctionEaseInEaseOut来获得更好的动画效果,但我不会对核心动画做同样的想法我正在尝试这个:
[CATransaction begin];
[CATransaction setAnimationDuration:.5f];
[CATransaction setAnimationTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
scene.carte17.layer.position = positionInit;
if (scene.carte17.angleCarte == 15.f) {
CABasicAnimation *animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat:0.0];
animation.toValue = [NSValue valueWithCGAffineTransform:CGAffineTransformRotate(scene.carte17.transform, degreesToRadians(30))];
animation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut];
animation.delegate = self;
[scene.carte17.layer addAnimation:animation forKey:@"rotationAnimation"];
scene.carte17.angleCarte = 45.f;
}
[CATransaction commit];
但它不起作用......你能帮帮我吗?
答案 0 :(得分:0)
为什么不这样称呼:
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
但由于UIViewAnimationCurveEaseInOut
是默认值,因此这是一种过度杀伤。