开发者

ios CoreAnimation

I'm trying to skew an object cards it's an UIView I'm doing :

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

And it's working ! My card incline to 30° and it's good. I'm playing with setAnimationDuration to control the speed.

I would like to use CoreAnimation and kCAMediaTimingFunctionEaseInEaseOut to have a better animation but I'm not ok to do the same think with core animation I'm trying this :

[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.c开发者_JS百科arte17.angleCarte = 45.f;
}
[CATransaction commit];

But it's not working ... Could you help me please !


Why not just call this:

[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

But that is an overkill since UIViewAnimationCurveEaseInOut is the default value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜