Animate UIView宽度不起作用

时间:2017-01-25 09:20:52

标签: ios animation uiview uiviewanimation

尝试像这样设置UIView的宽度。但它没有做任何事情。为什么?评论的部分更改了视图的alpha,并且可以正常工作。

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
})

1 个答案:

答案 0 :(得分:0)

我想你需要将调用与layoutIfNeeded()集成,这要求自动布局立即强制布局。

相关问题