user2491253
user2491253

Reputation: 55

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?

Upvotes: 1

Views: 909

Answers (1)

jszumski
jszumski

Reputation: 7416

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.

Upvotes: 7

Related Questions