異なるUIViewアニメーションを同時に書くことができるかどうか疑問に思います。スプライトアニメーションを同時に使用して、2つのAppleスタイルのフリップカウンターをアニメーション化しようとしています。各フリップカウンターには独自のアニメーションがあります。問題は、最初のカウンターが終了すると、2番目のフリップカウンターが実行を開始することです。
2回編集:コードは次のとおりです: https ://dl.dropbox.com/u/1348024/MultipleFlipCounters.zip
「FlipCounterView.m」と「CounterViewController」の2つの単純なクラスがあります。画面「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];
}];
}