我尝试使用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:抱歉我的英文不好
答案 0 :(得分:2)
您的animationDuration
太小了。 您强制对象以比其最大可能性更快的速度显示您的所有帧。
来自Apple文档:
持续时间以秒为单位。默认值 property等于图像数乘以1/30 第二。因此,如果您有30张图像,则该值为1秒。
这意味着如果你有24 images
,至少你必须将0.8
设置为持续时间。(24/30)。