ios - How to fade in and out an ActivityIndicator in Swift? -
here activity indicator:
self.activityindicator = uiactivityindicatorview(activityindicatorstyle: uiactivityindicatorviewstyle.whitelarge) self.activityindicator.center = self.view.center self.view.addsubview(activityindicator)
i can start self.activityindicator.startanimating()
, stop self.activityindicator.stopanimating()
. i'd transition when stops more fluid , think nice fade out element on 400 milliseconds rather hiding when call stopanimating.
any ideas on how this?
// set initial state self.activityindicator.alpha = 0.0 // show self.activityindicator.startanimating() uiview.animatewithduration(0.4) { self.activityindicator.alpha = 1.0 } // hide uiview.animatewithduration(0.4, animations: { self.activityindicator.alpha = 0.0 }) { complete in self.activityindicator.stopanimating() }
Comments
Post a Comment