gpt4 book ai didi

uiimageview - 如何在 uiimageview 上放置抖动动画?

转载 作者:行者123 更新时间:2023-12-04 22:21:35 28 4
gpt4 key购买 nike

我一直在尝试实现这一点,但找不到任何可以在删除它们时像 iPhone 应用程序抖动一样抖动它的代码!

CABasicAnimation *animation = 
[CABasicAnimation animationWithKeyPath:@"position"];
[animation setDuration:0.05];
[animation setRepeatCount:8];
[animation setAutoreverses:YES];
[animation setFromValue:[NSValue valueWithCGPoint:
CGPointMake([lockView center].x - 20.0f, [lockView center].y)]];
[animation setToValue:[NSValue valueWithCGPoint:
CGPointMake([lockView center].x + 20.0f, [lockView center].y)]];
[[lockView layer] addAnimation:animation forKey:@"position"];

最佳答案

您可以通过以下代码实现此目的,您已经定义了从和到的旋转角度。

CABasicAnimation* anim = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
[anim setToValue:[NSNumber numberWithFloat:0.0f]];
[anim setFromValue:[NSNumber numberWithDouble:M_PI/16]]; // rotation angle
[anim setDuration:0.1];
[anim setRepeatCount:NSUIntegerMax];
[anim setAutoreverses:YES];
[[imageView layer] addAnimation:anim forKey:@"iconShake"];

关于uiimageview - 如何在 uiimageview 上放置抖动动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16891720/

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