简体   繁体   中英

UIView animateWithDuration:delay:options:animate:completion not delaying

I've seen a few questions related to this here at SO, but none of them seem to quite answer this: the delay part of UIView animateWithDuration:delay:options:animate:completion: won't delay. Here is the actual code that calls it:

-(void) viewDidAppear:(BOOL)animated
{
    NSLog(@"about to start animateWithDuration...");

    [UIView animateWithDuration:3.0 delay:2.0 options:UIViewAnimationOptionTransitionNone
                     animations:^{NSLog(@"in the animations block..."); self.textView.hidden = YES;}
                     completion:^(BOOL finished){if (finished) {NSLog(@"In the completion block..."); self.textView.hidden = NO; [self.player play];}}];
}

And here is the NSLog timestamps:

2013-06-18 15:27:16.607 AppTest1[52083:c07] about to start animateWithDuration...

2013-06-18 15:27:16.608 AppTest1[52083:c07] in the animations block...

2013-06-18 15:27:16.609 AppTest1[52083:c07] In the completion block...

As one can see, the instructions are being performed milliseconds apart, and not 2 or 3 seconds delayed. Would anyone know the reason for this?

The hidden property is not animatable:

The following properties of the UIView class are animatable:

@property frame

@property bounds

@property center

@property transform

@property alpha

@property backgroundColor

@property contentStretch

Try using one of those properties in your animation block and then the delay should occur. For example, you could animate the alpha from 1.0 to 0.0 and then hide it in the completion block.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM