Fade In Fade Out Animation

后端 未结 13 1250
生来不讨喜
生来不讨喜 2021-01-30 01:45

Here is some code I struggle with for a while.

If you start the fade in animation, the label text fades in. If I start the fade out animation the the label text fades ou

13条回答
  •  情深已故
    2021-01-30 02:10

    that does the job for you (the _label is your label);

    - (IBAction)startFade:(id)sender {
        [_label setAlpha:0.f];
    
        [UIView animateWithDuration:2.f delay:0.f options:UIViewAnimationOptionCurveEaseIn animations:^{
            [_label setAlpha:1.f];
        } completion:^(BOOL finished) {
            [UIView animateWithDuration:2.f delay:0.f options:UIViewAnimationOptionCurveEaseInOut animations:^{
                [_label setAlpha:0.f];
            } completion:nil];
        }];
    }
    

提交回复
热议问题