UIView.transition with delay

Viewed 2283

I have simultaneous animations going on, and I would like to transition the VC in the middle (it will fade so it will see some of the other animations). However, I can't find documentation how to delay a transition similar to UIView.animateWithDuration.

I want to achieve this...

UIView.transition(withDuration: 0.5, delay: 0.1, options: .transitionCrossDissolve, animations: {})

I can manually add a delay like so.. but was wondering if there's a more elegant way.

DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {}
1 Answers

Unfortunately no. Using a bunch of UIView transitions/animations can get a little hairy.

In the past, I've resorted to setting up an NSTimer that fires 1/30 seconds and I ended up managing all the start times on my own.

What you can do is series out the animations using the closure.

UIView.animate(withDuration: 1, animations: { 
}, completion: {Do UIView transition here})
Related