gpt4 book ai didi

objective-c - 旋转 NSButton 不起作用

转载 作者:行者123 更新时间:2023-12-03 17:48:16 25 4
gpt4 key购买 nike

我有对角线向下动画的代码。

CABasicAnimation *rightAnimation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
[rightAnimation setToValue:[NSNumber numberWithFloat:160]];
[rightAnimation setBeginTime:0.0];
[rightAnimation setDuration:0.4];


CABasicAnimation *fall = [CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
[fall setToValue:[NSNumber numberWithFloat:-20]];
[fall setBeginTime:0.1];
[fall setDuration:0.3];

//DOESN'T WORK
CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform.translation.z"];
[rotate setToValue:[NSNumber numberWithFloat:DEGREES_RADIANS(30)]];
[rotate setBeginTime:0.0];
[rotate setDuration:0.4];

CAAnimationGroup *group = [CAAnimationGroup animation];
[group setDuration:0.4];
[group setAnimations:[NSArray arrayWithObjects:rightAnimation, fall, rotate, nil]];

[submitButton.layer addAnimation:rotate forKey:nil];

除了我还希望按钮旋转 30 度之外,它工作得非常好。但由于某种奇怪的原因,这并没有发生,为什么呢?

最佳答案

更改此行:

CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform.translation.z"];

对此:

CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];

这应该可以解决您的问题。

关于objective-c - 旋转 NSButton 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42029926/

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