How to force a view to render itself?

前端 未结 4 1354
自闭症患者
自闭症患者 2020-12-13 07:24

In my app I have a number of small subviews. When the user taps a subview, I place one separate view over top of the tapped subview (same size) and then animate this separa

4条回答
  •  被撕碎了的回忆
    2020-12-13 08:14

    The proper way to do this is to simply divide up your method.

    Just call setNeedsDisplay, then return without animating. Wait until the drawRect that sets everything up correctly has finished its redraw, and then have it queue up another method that starts your desired animation (via queuing an operation or a notification). Then start the animation. This can all happen fairly quickly (at frame rate), and involves no extra (dangerous) recursive run loop calls or CATransaction calls (which may cause extra GPU setups).

提交回复
热议问题