gpt4 book ai didi

ios核心动画

转载 作者:行者123 更新时间:2023-11-28 17:44:13 38 4
gpt4 key购买 nike

我正在尝试倾斜对象卡,这是我正在做的 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];

但它不起作用......请你帮帮我!

最佳答案

为什么不直接调用它:

[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

但这有点矫枉过正,因为 UIViewAnimationCurveEaseInOut 是默认值。

关于ios核心动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6875821/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com