开发者

How can I make an animated UIImage move across the screen?

I would like to move an animated UIImage across the screen. How is this possible?

Here is my code so far with UIImage animation:

self.myI开发者_C百科mageWalk.animationImages = [NSArray arrayWithObjects:[UIImage imageNamed:@"img01.png"],[UIImage imageNamed:@"img02.png"], [UIImage imageNamed:@"img03.png"], [UIImage imageNamed:@"img04.png"], nil];

[self.myImageWalk setAnimationRepeatCount:5];
[self.myImageWalk setAnimationDuration:2];
[self.myImageWalk startAnimating];


declare this function .h file

-(void)doAnimate:(CGRect)rect;

.m file

-(void)doAnimate:(CGRect)rect{


    [UIView animateWithDuration:2.0 delay:0.5 options:UIViewAnimationCurveEaseInOut animations:^() {


        self.myImageWalk.frame=rect;


    } completion:^(BOOL finished) {

        NSLog(@"animation Done");
    }];


}

then call wherever u want to animate

     [self doAnimate:CGRectMake(300, 300, self.myImageWalk.frame.size.width, self.myImageWalk.frame.size.height)];

here change 300,300 to ur wish to get animate to various position.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜