I need to do series of animation on 4 different images. The images are arranged in sequence. It will begin with movement of first image and when it stops the second one will move and similarly others will follow. Can someone please help me?
Thanks in advance
Pankaj
Answer
[UIView animateWithDuration:2.0
animations:^{
ballon1.center = CGPointMake(260, 50);
}
completion:^(BOOL finished){
[UIView animateWithDuration:1.5
animations:^{
ballon2.center = CGPointMake(260, 140);
}
completion:^(BOOL finished){
[UIView animateWithDuration:1.0
animations:^{
ballon3.center = CGPointMake(260, 230);
}
completion:^(BOOL finished){
[UIView animateWithDuration:1.0
animations:^{
ballon4.center = CGPointMake(260, 320);
}
completion:^(BOOL finished){
开发者_JAVA百科 ;
}];
}];
}
];
}];
You can do something like this:
[UIView animateWithDuration:1 animations:^{
self.image1.frame = [self frameForImage1];
} completion:^(BOOL finished){
[UIView animateWithDuration:1 animations:^{
self.image2.frame = [self frameForImage2];
} completion:^(BOOL finished){
// etc. for images 3 and 4
}];
}];
Or if you'd rather do your animations using beginAnimations:context:
and commitAnimation
, then you can use setAnimationDelegate:
and setAnimationDidStopSelector:
to chain together a series of selectors to animate each image.
I think you are asking for image animation with time count...If so you can use this
UIImageView *animView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 855, 768, 92)];
animView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"01.jpg"],
[UIImage imageNamed:@"02.jpg"],
[UIImage imageNamed:@"03.jpg"],nil];
// all frames will execute in 1.5 seconds
animView.animationDuration = 7;
// repeat the annimation forever
animView.animationRepeatCount = 0;
// start animating
[animView startAnimating];
// add the animation view to the main window
[webView addSubview:animView];
Hope this helps you.
精彩评论