簡體   English   中英

動畫UIView寬度不起作用

[英]Animate UIView width does not work

嘗試像這樣對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
})

我猜您需要將調用與layoutIfNeeded()集成在一起,這會要求自動布局立即強制布局。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM