UIImageViewをUIViewにスライドさせ、同時にフェードインしようとしています。そして、それをフェードアウトさせてスライドさせたいのです。以下のコードはこれを行う必要がありますが、そうではありません。代わりに、leftArrowビューはスライドイン時に完全なアルファ状態になります。したがって、最初のアニメーションはアルファフェードインをスキップします。次に、2番目のアニメーションはフェードアウトするだけで、leftArrowビューは移動しません。私は多くのバリエーションを試しました(フレームの代わりに境界を使用し、(インスタンスメソッドではなく)クラスメソッドでアニメーションを実行しましたが、ビューが他の方法ではなく一方の方法を任意に選択しているように見える理由を判断できません。または両方。たぶん私は新鮮な目が必要です。TIA、マイク
- (void) flashHorizontalArrowsForView: (UIView *)view {
DebugLog(@" flashHorizontalArrows");
float duration = 1.5f;
// create the views
UIImageView *leftArrow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"leftCouponDetailArrow.png"]];
leftArrow.frame = CGRectMake(0 -leftArrow.image.size.width,
HORIZONTAL_ARROW_START_Y,
leftArrow.image.size.width,
leftArrow.image.size.height);
[view addSubview:leftArrow];
leftArrow.alpha = 0.0f;
// animate them in...
[UIView beginAnimations:@"foo" context:leftArrow];
[UIView setAnimationDelay: 0.0f ]; // in seconds
[UIView setAnimationDuration: duration ];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDidStopSelector:@selector(animationReallyDidStop:finished:context:)];
[UIView setAnimationDelegate:self];
leftArrow.alpha = 1.0f;
CGRect LFrame = leftArrow.frame;
LFrame.origin.x += LFrame.size.width; // move it in from the left.
leftArrow.frame = LFrame;
[UIView commitAnimations];
// and animate them out
// delay enough for the first one to finish
[UIView beginAnimations:@"bar" context:leftArrow];
[UIView setAnimationDelay: duration+0.05 ]; // in seconds
[UIView setAnimationDuration: duration ];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDidStopSelector:@selector(animationReallyDidStop:finished:context:)];
[UIView setAnimationDelegate:self];
leftArrow.alpha = 0.0f;
CGRect LLFrame = leftArrow.bounds;
LLFrame.origin.x -= LLFrame.size.width; // move it off to the left.
leftArrow.bounds = LLFrame;
[UIView commitAnimations];
}