Search code examples
swiftuiviewcore-animationcashapelayercadisplaylink

CADisplayLink catches animation with delay


Trying to reproduce behaviour described in this article. Line by line. Everything works well but the last step...

The problem is: I unpause CADisplayLink just before calling UIView.animate and expect the unpaused CADisplayLink to call the attached selector on main thread during animation. It does work, but it starts to call the attached selector with a half a second delay.

Any suggestions?

enter image description here


Solution

  • It seems that you've chosen a wrong RunLoopMode. With RunLoopMode.commonModes it works like a charm. Look here for a detailed answer.