user2049921
user2049921

Reputation: 91

animateWithDuration can't fade in and out

I want to preform a fade out followed by a fade in on my label, i can get both to work separately but not together.

    [UILabel animateWithDuration:1.0 animations:^{
        _swixValla.alpha = 0.0;
        _skigoValla.alpha = 0.0;
        _rodeValla.alpha = 0.0;
        _startValla.alpha = 0.0;
    }];


    [UILabel animateWithDuration:1.0 animations:^{
        _swixValla.alpha = 1.0;
        _skigoValla.alpha = 1.0;
        _rodeValla.alpha = 1.0;
        _startValla.alpha = 1.0;
    }];

This does not work

    [UILabel animateWithDuration:1.0 animations:^{
        _swixValla.alpha = 0.0;
        _skigoValla.alpha = 0.0;
        _rodeValla.alpha = 0.0;
        _startValla.alpha = 0.0;


    [UILabel animateWithDuration:1.0 animations:^{
        _swixValla.alpha = 1.0;
        _skigoValla.alpha = 1.0;
        _rodeValla.alpha = 1.0;
        _startValla.alpha = 1.0;
    }];
    }];

This does not work either.

How can i solve this?

Upvotes: 0

Views: 1282

Answers (1)

Grzegorz Krukowski
Grzegorz Krukowski

Reputation: 19872

If you want to combine them to start the second one after first one is done use:

[UIView animateWithDuration:1.0 animations:^{
    _swixValla.alpha = 0.0;
    _skigoValla.alpha = 0.0;
    _rodeValla.alpha = 0.0;
    _startValla.alpha = 0.0;
}completion:^(BOOL finished){
    [UILabel animateWithDuration:1.0 animations:^{
        _swixValla.alpha = 1.0;
        _skigoValla.alpha = 1.0;
        _rodeValla.alpha = 1.0;
        _startValla.alpha = 1.0;
    }];
}];

Upvotes: 2

Related Questions