han*_*Dev 1 iphone objective-c uiimageview
第一个动画结束后,我很难将图像移动到另一个位置.
图像在我指定的点处动画,然后停止(工作正常).然后我想将图像移动到另一个位置并重复.
这是我的代码:
-(void) loadTap {
NSArray *imageArray = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"tap1.png"],
[UIImage imageNamed:@"tap2.png"],
[UIImage imageNamed:@"tap3.png"],
[UIImage imageNamed:@"tap4.png"],
nil];
tapImage.animationImages = imageArray;
tapImage.animationRepeatCount = 1;
[imageArray release];
tapImage.animationDuration = 1;
tapImage.animationRepeatCount = 20;
[tapImage startAnimating];
tapImage.center = CGPointMake(156, 110);
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.
为了移动图像,您应该将代码包含在动画块中移动:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
tapImage.center = CGPointMake(156, 110);
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)
您还可以使用方法在完成动画时执行一个UIView setAnimationDidStopSelector:方法.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animateImages)];
tapImage.center = CGPointMake(156, 110);
[UIView commitAnimations];
//other stuff
-(void)animateImages{
[tapImage startAnimating];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7014 次 |
| 最近记录: |