2011-01-29 78 views
0


我尝试在我的应用程序中为背景添加动画。如何为背景设置动画?

我使用图像视图与图像和视图加载我开始了一个定时器滚动图像。
这一切都好,我递减x和图像似乎是动画。

但是,当图像结束(对我来说800像素)I RESET X为0,我看到一个丑陋的动画...

有没有更好的办法来解决这个简单的动画?

[...] 
[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(scrollBackground) userInfo:nil repeats:YES]; 
[,,,] 
int x = 0; 

- (void) scrollBackground { 
    if (x <= -480) x = 0; 

    [background setFrame:CGRectMake(x--, background.frame.origin.y, background.frame.size.width, background.frame.size.height)]; 
} 

感谢

+0

解决方法使用:CABasicAnimation animationWithKeyPath:@“transform.translation.x”] – elp 2011-01-29 20:53:49

回答

0

什么是 “丑陋的动画” 是什么意思? 如果图像以类似的方式结束,它可能是好的,在-480处,图像应该与x = 0处的图像相同 假定围绕它具有纹理的cilinder,在结合处您会看到只有当图像与同一图像的开头不同时才有区别。

+0

不好意思,当它到达它会去,回到0,这种效果不好... – elp 2011-01-29 20:49:13