Alexander Alexander - 4 months ago 38
Swift Question

UICollectionView cell. trying to animate subviews

trying to animate a subview inside a collection view cell but am only getting an abrupt change between states.

...

func animate (){
if self.signOut.hidden == false{
UIView.animateWithDuration(0.2) {
self.signOut.hidden = true
}
}else{
UIView.animateWithDuration(0.2) {
self.signOut.hidden = false
}
}

...


any tips much appreciated!

Answer

You need to decrease the alpha inside an animation block for the view to disappear smoothly

      UIView.animateWithDuration(0.33, delay: 0.0, options: [.CurveEaseInOut], animations: {
            self.signOut.alpha = 0.0
        }) { finished in
            self.signOut.hidden = true
        }
Comments