我怎样才能不断移动视图?

时间:2011-01-19 12:11:24

标签: iphone cocoa-touch

我想创建一个简单的应用程序,我想在其中创建一个持续动画的道路。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

我使用了UIScrollView。然后,设置运行以下内容的NSTimer:


-(void)scroll{
    CGPoint currentPoint = playerStatsRect.contentOffset;
    CGPoint scrollPoint = CGPointMake(currentPoint.x, currentPoint.y + 1);
    [playerStatsRect setContentOffset:scrollPoint animated:NO];

    if(scrollPoint.y == playerStatsRect.contentSize.height+5)//If we've reached the bottom, reset slightly past top, to give ticker look
    {
        [playerStatsRect setContentOffset:CGPointMake (0,-125)];
    }
}

希望这会有所帮助:)