我想在我的应用程序中来回摆动图像,类似于当你按下它时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)
或者可能有一个我只是缺少的完全简单的解决方案.感谢任何指针.谢谢!
我正在开发一个应用程序,需要在1小时内将imageview的宽度从320减少到0.为此,我使用以下代码
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:3600];
newRect.size.width = 0;
imgView.frame = newRect;
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)
如果我们停留在相同的视图控制器中,如果用户导航到其他一个viewcontoller,如何处理动画,则动画启动后,它可以正常工作.
除此之外我还有一个问题 - 在动画期间,imageview中的图像看起来像整个动画中缩小我正在使用相同的图像,所以我想在动画期间更改imageView中的图像我该如何实现这一点.
除了动画之外还有其他任何方法吗?
任何帮助都会得到赞赏.
好吧,我正在寻找一种方法来更改我的微调器图像并使用自定义图像
有什么建议吗?
iphone customization image objective-c uiactivityindicatorview