2012-01-07 88 views
2

如何使用iOS中的图像创建连续动画? 我想创建一个循环动作,其中我的imageView保持在屏幕边界内,但x轴始终向前,因此它基本上会生成动画效果..所以我只能使用一个图像。任何帮助将不胜感激!!想法?如何使用iOS中的图像创建连续动画

我的图像是800 * 12像素的大图像。

回答

5

您可以使用UIImageViewanimationImages属性动画动画的框架:

UIImageView *view = // etc. 

UIImage *frame1 = [UIImage imageNamed:@"1.png"]; 
UIImage *frame2 = [UIImage imageNamed:@"2.png"]; 
// etc. 

view.animationImages = [NSArray arrayWithObjects:frame1, frame2, ..., nil]; 

view.animationDuration = 1.0; 
view.animationRepeatCount = 0; 

[view startAnimating]; 
+0

感谢这一点,但我该怎么办使用一个图像通过设置其x位置..使用没有任何其他方式这imageview动画... – 2012-01-07 15:28:47

+0

PLZ看看我编辑的问题 – 2012-01-07 15:51:28