views:

45

answers:

1

I have a view with which I have a button calling the following method. The view hides/shows but without any animation

- (void) displayEvent:(id)sender {

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:2.5];
    modal.hidden = !modal.hidden;
    [UIView commitAnimations];
}

Any ideas?

+3  A: 

There's no states in between hidden and non-hidden. How to animate?

To have the fade-in effect you should modify the alpha property.

- (void) displayEvent:(id)sender {
    BOOL wasHidden = modal.hidden;
    modal.hidden = ! wasHidden;
    modal.alpha = ! wasHidden; // wasHidden ? 0 : 1;
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:2.5];
    modal.alpha = wasHidden; // wasHidden ? 1 : 0;    
    [UIView commitAnimations];
}
KennyTM