gpt4 book ai didi

objective-c - iOS CAKeyFrameAnimation 旋转

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:55:41 25 4
gpt4 key购买 nike

我编写了此 CAKEyFrameAnimaton 以在其 X 轴上旋转 CALayer。但它不旋转。我在这里做错了什么?

CAKeyframeAnimation *topFoldAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.x"];
topFoldAnimation.duration = 15;
topFoldAnimation.repeatCount = 1;
topFoldAnimation.removedOnCompletion = NO;
topFoldAnimation.autoreverses = NO;
topFoldAnimation.fillMode = kCAFillModeForwards;

CATransform3D tTrans = CATransform3DIdentity;
tTrans.m34 = -1/900;

topFoldAnimation.values = [NSArray arrayWithObjects:
[NSValue valueWithCATransform3D:CATransform3DRotate(tTrans,DEGREES_TO_RADIANS(0),1,0,0)],
[NSValue valueWithCATransform3D:CATransform3DRotate(tTrans,DEGREES_TO_RADIANS(-30),1,0,0)],
[NSValue valueWithCATransform3D:CATransform3DRotate(tTrans,DEGREES_TO_RADIANS(-60),1,0,0)],
[NSValue valueWithCATransform3D:CATransform3DRotate(tTrans,DEGREES_TO_RADIANS(-90),1,0,0)],
nil];
topFoldAnimation.keyTimes = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.00],
[NSNumber numberWithFloat:0.25],
[NSNumber numberWithFloat:0.50],
[NSNumber numberWithFloat:1.00],
nil];
topFoldAnimation.timingFunctions = [NSArray arrayWithObjects:
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear],
nil];
[[backgroundAnimationLayer.sublayers objectAtIndex:1] addAnimation:topFoldAnimation forKey:@"transform.rotation.x"];

感谢任何帮助。谢谢...

最佳答案

你的动画 keyPath 是错误的,它应该只是 transform 而不是 transform.rotation.x

此外,您将在 tTrans.m34 中得到 0,因为您使用的是整数除法。它可能应该是 -1.0/900

关于objective-c - iOS CAKeyFrameAnimation 旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7204607/

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