相关疑难解决方法(0)

如何创建iPhone的摇摆图标效果?

我想在我的应用程序中来回摆动图像,类似于当你按下它时iPhone图标的摆动.最好的方法是什么?

这是我第一次涉足不使用动画GIF的动画.我认为这个想法是来回轻微旋转图像以产生摆动效果.我已经看过使用CABasicAnimation和CAKeyframeAnimation.CABasicAnimation每次重复时都会创建一个抖动,因为它会跳转到from位置并且不会向内插回.CAKeyframeAnimation似乎是解决方案,除了我无法让它工作.我肯定错过了什么.这是我使用CAKeyframeAnimation的代码(不起作用):

    NSString *keypath = @"wobbleImage";
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:keypath];
animation.duration = 1.0f;
animation.delegate = self;
animation.repeatCount = 5;

CGFloat wobbleAngle = 0.0872664626f;
NSValue *initial = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0.0f, 0.0f, 0.0f, 1.0f)];
NSValue *middle = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(wobbleAngle, 0.0f, 0.0f, 1.0f)];
NSValue *final = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(-wobbleAngle, 0.0f, 0.0f, 1.0f)];
animation.values = [NSArray arrayWithObjects:initial, middle, final, nil];

[imageView.layer addAnimation:animation forKey:keypath];
Run Code Online (Sandbox Code Playgroud)


或者可能有一个我只是缺少的完全简单的解决方案.感谢任何指针.谢谢!

iphone animation rotation ios

52
推荐指数
4
解决办法
4万
查看次数

按钮动画像ios游戏中心按钮

我想让我的按钮像ios游戏中心的按钮一样生动.它们似乎像泡沫一样在屏幕上摆动和漂浮.我已经尝试在屏幕上随机移动我的按钮,让它们同时在一个恒定的圆形路径中移动,但效果并不相同.

我需要一种摆动的效果.任何想法都表示赞赏

animation button ios game-center

6
推荐指数
1
解决办法
3944
查看次数

标签 统计

animation ×2

ios ×2

button ×1

game-center ×1

iphone ×1

rotation ×1