Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Call animateWithDuration inside dispatch_async

I've call an web API to get the result. After getting response I want to remove "visualIndicatorView" (UIView) with indication using animation function. Indication and View come to hidden state but not smoothly.

Here is my code:

dispatch_async(dispatch_get_main_queue()) {
    UIView.animateWithDuration(2.0, animations: { () -> Void in
         self.activityIndicator.hidden = true
         self.visualIndicatorView.hidden = true
         self.activityIndicator.stopAnimating()
}) { (completed:Bool) -> Void in
}
like image 631
Avim Avatar asked Jun 22 '26 02:06

Avim


1 Answers

hidden is not an animatable property. Try setting alpha to 0:

self.visualIndicatorView.alpha = 0.0
self.activityIndicator.alpha = 0.0
like image 131
Ozgur Vatansever Avatar answered Jun 24 '26 15:06

Ozgur Vatansever