【发布时间】:2012-10-14 20:25:15
【问题描述】:
我想知道是否可以同时编写不同的 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];
}];
}
【问题讨论】:
-
请在您的问题中包含相关的 CCD -- 没有人愿意下载您的整个项目。
-
哦,顺便说一句,你的代码崩溃了