Redrawing a UIView with a fade animation?

前端 未结 2 611
孤城傲影
孤城傲影 2021-01-30 18:30

In TwUI, there is a method called redraw on TUIView. It forces the view to redraw, but it also comes with a free fading animation between

相关标签:
2条回答
  • 2021-01-30 18:51

    Use +[UIView transitionWithView:duration:options:animations:completion:] with the UIViewAnimationOptionTransitionCrossDissolve option, and inside the animation block, force the view's layer to redraw its contents immediately.

    [myView setNeedsDisplay];
    [UIView transitionWithView:myView duration:1
        options:UIViewAnimationOptionTransitionCrossDissolve
        animations:^{
            [myView.layer displayIfNeeded];
        } completion:nil];
    
    0 讨论(0)
  • 2021-01-30 19:01

    How about using a cross-dissolve UIView transition?

    [UIView transitionWithView:aView 
                      duration:TIME_INTERVAL 
                       options:UIViewAnimationOptionTransitionCrossDissolve 
                    animations:^{
                        // Change the view's state
                    } 
                    completion:^(BOOL finished) {
                        // Completion block
                    }];
    
    0 讨论(0)
提交回复
热议问题