我想知道是否可以同时编写不同的 UIView 动画。我试图同时使用精灵动画为两个 Apple 风格的翻转计数器设置动画。每个翻转计数器都有自己的动画。问题是当第一个计数器完成时,第二个翻转计数器开始运行。
两次编辑:这是代码: https ://dl.dropbox.com/u/1348024/MultipleFlipCounters.zip
有两个简单的类“FlipCounterView.m”和“CounterViewController”。点击屏幕“CounterViewController”将启动动画。谢谢!
编辑:
添加了相关代码。
Apple 风格的翻转计数器精灵动画是在 FlipCounterView 类中完成的。
- (void)viewDidLoad{
[super viewDidLoad];
flipCounter1 = [[FlipCounterView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
[flipCounter1 add:10];
[self.view addSubview:flipCounter1];
flipCounter2 = [[FlipCounterView alloc] initWithFrame:CGRectMake(0, 120, 200, 200)];
[flipCounter2 add:10];
[self.view addSubview:flipCounter2];
}
敲击画面:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[UIView animateWithDuration:0.5
animations:^{
//this method made an sprite animation on flipCounter1
[flipCounter1 distributedAdd:150 overSeconds:0 withNumberOfIterations:3];
}];
[UIView animateWithDuration:0.5
animations:^{
//this method made an sprite animation on flipCounter2
[flipCounter2 distributedAdd:150 overSeconds:0 withNumberOfIterations:3];
}];
}