0
我试图将UIImageView滑入UIView,并在同一时间淡入。然后我希望它淡入淡出。 下面的代码应该这样做,但它不。 而是,leftArrow视图在滑入时处于完全alpha状态。因此,第一个动画正在跳过Alpha渐入式。然后第二个动画只是淡出它,它不会移动leftArrow视图。我已经尝试了很多变体(使用边界而不是框架,在类方法(而不是实例方法)中执行动画),并且我无法确定视图为什么会随意选择一个要做的事而不是另一个, 。或者两者 也许我只是需要新鲜的眼光 TIA, 迈克简单的UIView动画链不工作
- (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];
}
顺便说一句,我跑了XCode 3.2.4,而这个动画失败与4.1 iPhone模拟器,和3.1.3的设备。 – Rayfleck 2010-11-18 15:29:33