Я пытаюсь запустить этот обработчик завершения после уменьшения метки, но он вызывается в самом начале функции. Я просмотрел несколько руководств и прочел документацию, но не могу понять, что не так с моим кодом.
func fadeViewInThenOut(view : UILabel, delay: TimeInterval, completion: () -> () ) {
let animationDuration = 1.00
// Fade in the view
UIView.animate(withDuration: animationDuration, delay: 1, animations: { () -> Void in
view.alpha = 1
}) { (Bool) -> Void in
// After the animation completes, fade out the view after a delay
UIView.animate(withDuration: animationDuration, delay: delay, animations: { () -> Void in
view.alpha = 0
}, completion: nil)
}
completion()
}
fadeViewInThenOut(view: newwelcomeLabel, delay: 5) {
print("hello")
}