简体   繁体   English

UIImageView动画

[英]UIImageView animation

I need to animate and imageview, first rotate it in one direction, shift the center and rotate it in the opposite direction in a single animation loop. 我需要设置动画和imageview,首先在一个动画循环中向一个方向旋转,移动中心并向相反方向旋转。

What i did was :: 我所做的是::

[UIImageView beginAnimations:nil context:NULL];
[UIImageView setAnimationDuration:2.0];
[UIImageView setAnimationDelegate:self];
[UIImageView setAnimationWillStartSelector:@selector(setRightAngle)];

image.center = CGPointMake(newCenter.x, newCenter.y) ;

[UIImageView setAnimationDidStopSelector:@selector(setStraight)];
[UIImageView commitAnimations];

This is getting the job done, but it happens in 3 steps that is noticeable on the screen. 这可以完成工作,但是它需要3个步骤,在屏幕上可以明显看到。 it first turns right,then shifts the center and the set the image to the default angle. 它首先向右转,然后移动中心并将图像设置为默认角度。 i want to remove that noticeable breaks in between to achieve a smooth animation. 我想删除两者之间的明显中断以实现流畅的动画。 Can some one suggest me a better approach to this issue? 有人可以建议我对这个问题采取更好的方法吗?

Thanks & Regards, NR 致谢,NR

You might want to post your setStraight and setRightAngle methods. 您可能想要发布setStraight和setRightAngle方法。

You could also look into formatting the code in your question for better readability. 您也可以考虑格式化问题中的代码以提高可读性。

Since you have noticeable breaks, you could add a timer, and see when your methods are firing, to see when the breaks occur. 由于您有明显的中断,因此可以添加一个计时器,并查看触发方法的时间,以查看中断发生的时间。

I can say from experience that it is possible to use the technique you list here to have smooth animation. 我可以根据经验说,可以使用此处列出的技术来使动画流畅。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM