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
  • 29,667
  • 30
  • 151
  • 300

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
  • 25,454
  • 10
  • 82
  • 127