0

Try to animate the width of a UIView like this. But it does not do anything. Why? The commented part changes alpha of the view, and that works.

UIView.animate(withDuration: 1, delay: 0, options: [.curveEaseInOut], animations: {

    self.constraintLookupWidth.constant = 300
    self.viewLookup.setNeedsLayout()
    //self.viewLookup.alpha = 0.2

}, completion: {complete in

    self.constraintLookupWidth.constant = 200
    self.viewLookup.setNeedsLayout()
    //self.viewLookup.alpha = 1.0
})
János
  • 32,867
  • 38
  • 193
  • 353

1 Answers1

0

I guess that you need to integrate the call with a layoutIfNeeded(), this ask auto layout to force the layout right now.

Andrea
  • 26,120
  • 10
  • 85
  • 131