私のプロジェクトでは、ここにこれらのコードが 10 個あります。
- (void) makeAnim1{
//downward animation for carousel
[UIView animateWithDuration:**3.5**
delay:0.25
options: UIViewAnimationCurveLinear
animations:^{
carousel.frame = CGRectOffset(carousel.frame, 0, **490**);
}
completion:^(BOOL finished){ //task after an animation ends
[self performSelector:@selector(makeAnim1_1) withObject:nil afterDelay:3.0];
NSLog(@"Done!");
}];
}
- (void) makeAnim1_1{
//upward animation for carousel
[UIView animateWithDuration:**3.5**
delay:0.2
options: UIViewAnimationCurveLinear
animations:^{
carousel.frame = CGRectOffset(carousel.frame, 0, **-480**);
}
completion:^(BOOL finished){
//timer for the reveal button
[NSTimer scheduledTimerWithTimeInterval:0.1 //this arranges the duration of the scroll
target:self
selector:@selector(revealButton)
userInfo:nil
repeats:NO];
NSLog(@"Done!");
}];
}
たった 1 回の短い実装でそれらを作成したかったのです。したがって、それらは 1 つの関数にすぎません。必要な値を入れて、コードの太字バージョンに割り当ててみました。
互いに対応する 2 つの配列が必要です。例えば:
arrayA[3] = A、B、C;
arrayB[3] = a、b、c;
A が pick の場合、a に等しくなります。