我需要在4个不同的图像上做一系列动画。图像按顺序排列。它将从第一张图像的移动开始,当它停止时,第二张图像将移动,同样其他图像将跟随。有人可以帮助我吗?
提前致谢
的Pankaj
答案
[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){
;
}];
}];
}
];
}];
答案 0 :(得分:1)
您可以这样做:
[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
}];
}];
或者,如果您更愿意使用beginAnimations:context:
和commitAnimation
制作动画,则可以使用setAnimationDelegate:
和setAnimationDidStopSelector:
将一系列选择器链接在一起以设置每个动画的动画效果图像。
答案 1 :(得分:0)
我认为你要求时间计数的图像动画......如果是这样你可以使用这个
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];
希望这会对你有所帮助。