I am calling an animation in ViewDidAppear
, and then a bit later in ViewDidAppear
I am calling a function which creates several arrays of UIImage objects and takes 4-5 seconds to complete.
The animation meanwhile, is only 0.8 seconds long, and has a completion block:
UIView.animate(withDuration: 0.8, delay: 0.0, options: UIViewAnimationOptions(), animations: {
self.myView.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
}, completion: { finished in
self.nextTask()
})
The issue is that the completion block doesn't run 0.8 seconds later - it doesn't run until AFTER the previous code completes.
Is there anything I can do other than run that code in a background thread with DispatchQueue.global(qos: .background).async
? Or is there a way to improve the background thread's speed to completion?
My animation isn't interrupted if done in the background thread, but it takes much much longer to complete in the background - like 20-30 seconds instead of 4-5.
Thanks for any help you can share here!