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.
精彩评论