Redrawing a UIView with a fade animation?

前端 未结 2 613
孤城傲影
孤城傲影 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];
    

提交回复
热议问题