iphone - UIView animateWithDuration not respecting delay -
i want schedule series of animations animate intro text across screen. last animation, on completion, should fire off game tick logic should run game.
for reason happening immediately. can shed light on why happening or better alternative?
[self.view bringsubviewtofront:_viewintroseconds]; [uiview animatewithduration:0.4 delay:0.0 options:uiviewanimationoptioncurveeaseinout animations:^(void) { [_introlabel1 setalpha:1]; } completion:^(bool finished){ }]; [uiview animatewithduration:0.4 delay:3.0 options:uiviewanimationoptioncurveeaseinout animations:^(void) { [_introlabel2 setalpha:1]; [_introlabel1 setalpha:0]; [_introlabel1 setcenter:cgpointmake(0, _introlabel1.center.y)]; } completion:^(bool finished){ }]; [uiview animatewithduration:0.4 delay:5.0 options:uiviewanimationoptioncurveeaseinout animations:^(void) { [_introlabel3 setalpha:1]; [_introlabel2 setalpha:0]; [_introlabel2 setcenter:cgpointmake(0, _introlabel2.center.y)]; } completion:^(bool finished){ [self updategame]; [self updateclock]; [_viewintroseconds setalpha:0]; }];
my suggestion set delay
0, , place subsequent uiview
animation blocks in completion
block of previous animatewithduration
statements:
[uiview animatewithduration:0.4 delay:0.0 options:uiviewanimationoptioncurveeaseinout animations:^(void) { [_introlabel1 setalpha:1]; } completion:^(bool finished){ [uiview animatewithduration:0.4 delay:2.6 options:uiviewanimationoptioncurveeaseinout animations:^(void) { [_introlabel2 setalpha:1]; [_introlabel1 setalpha:0]; [_introlabel1 setcenter:cgpointmake(0, _introlabel1.center.y)]; } completion:^(bool finished){ [uiview animatewithduration:0.4 delay:1.6 options:uiviewanimationoptioncurveeaseinout animations:^(void) { [_introlabel3 setalpha:1]; [_introlabel2 setalpha:0]; [_introlabel2 setcenter:cgpointmake(0, _introlabel2.center.y)]; } completion:^(bool finished){ [self updategame]; [self updateclock]; [_viewintroseconds setalpha:0]; }]; }]; }];
this give desired effect.
edit : reason happening is, uiview animatewithduration
block begins animation, , moves on execute following code, while animation still in effect. hence advised perform 'next' animation effects in completion block. otherwise, animatewithduration
requests performed instantly.
edit 2: have edited delay
in blocks give 'illusion' of 0, 3, , 5 seconds respectively.
Comments
Post a Comment