开发者

How can I animate the road in iPhone Xcode?

开发者 https://www.devze.com 2023-02-05 22:19 出处:网络
I am going to animate the road, simply calling 1 image again and again from to开发者_高级运维p to bottom.Can anyone suggest how this is possible?You\'ll want to look at a UIScrollView. Put a UIImageVi

I am going to animate the road, simply calling 1 image again and again from to开发者_高级运维p to bottom. Can anyone suggest how this is possible?


You'll want to look at a UIScrollView. Put a UIImageView in it, then use the following code:


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

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

Run that code with a looping NSTimer and you'll be set :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号