ios CoreAnimation

ios CoreAnimation,ios,core-animation,Ios,Core Animation,我正在尝试倾斜一个对象,这是我正在做的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.tr

我正在尝试倾斜一个对象,这是我正在做的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和KCAMediatiming函数easeAseOut来制作更好的动画,但我不适合使用CoreAnimation,我正在尝试以下方法:

[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];

但它不起作用。。。你能帮帮我吗

为什么不直接称之为:

[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

但这太过分了,因为UIViewAnimationCurveEaseInOut是默认值。

谢谢你,PeyloW非常有用!我是新来的,我很难在CoreAnimation和UIKit中的动画之间做出准确的区别。。。但我正在努力@玛丽和我你能看看这个吗?