我尝试使用 ArrayWithObjects 来创建滚动的运动。 我有一个问题,我的动画停止并在数字九处重复:/
这是我的代码:
background.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"background_wall2.png"], [UIImage imageNamed:@"background_wall3.png"], [UIImage imageNamed:@"background_wall4.png"], [UIImage imageNamed:@"background_wall5.png"], [UIImage imageNamed:@"background_wall6.png"], [UIImage imageNamed:@"background_wall7.png"], [UIImage imageNamed:@"background_wall8.png"], [UIImage imageNamed:@"background_wall9.png"], [UIImage imageNamed:@"background_wall10.png"], [UIImage imageNamed:@"background_wall11.png"], [UIImage imageNamed:@"background_wall12.png"], [UIImage imageNamed:@"background_wall13.png"], [UIImage imageNamed:@"background_wall14.png"], [UIImage imageNamed:@"background_wall15.png"], [UIImage imageNamed:@"background_wall16.png"], [UIImage imageNamed:@"background_wall17.png"], [UIImage imageNamed:@"background_wall18.png"], [UIImage imageNamed:@"background_wall19.png"], [UIImage imageNamed:@"background_wall20.png"], [UIImage imageNamed:@"background_wall21.png"], [UIImage imageNamed:@"background_wall22.png"], [UIImage imageNamed:@"background_wall23.png"], [UIImage imageNamed:@"background_wall24.png"], [UIImage imageNamed:@"background_wall.png"], nil];
[background setAnimationRepeatCount:0];
background.animationDuration = 0.3;
[background startAnimating];
你能帮帮我吗?
提前致谢
PS:抱歉我的英语不好
最佳答案
您的animationDuration
太小了。 您强制对象以比其最大可能性更快的速度呈现您的所有框架。
来自 Apple 文档:
The time duration is measured in seconds. The default value of this property is equal to the number of images multiplied by 1/30th of a second. Thus, if you had 30 images, the value would be 1 second.
这意味着如果您有24 张图片
,至少您必须将0.8
设置为持续时间。 (24/30)。
关于IOS NSArray arrayWithObjects,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23788463/