Ios 设置UIView宽度的动画不起作用
尝试像这样设置Ios 设置UIView宽度的动画不起作用,ios,animation,uiview,uiviewanimation,Ios,Animation,Uiview,Uiviewanimation,尝试像这样设置ui视图的宽度动画。但它没有任何作用。为什么?注释的部分会更改视图的alpha,这是可行的 UIView.animate(withDuration: 1, delay: 0, options: [.curveEaseInOut], animations: { self.constraintLookupWidth.constant = 300 self.viewLookup.setNeedsLayout() //self.viewLookup.alpha =
ui视图的宽度动画。但它没有任何作用。为什么?注释的部分会更改视图的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
})
我想您需要将调用与layoutifneed()
集成,这要求自动布局立即强制布局