Animate intrinsicContentSize changes

后端 未结 6 811
借酒劲吻你
借酒劲吻你 2021-01-30 08:15

I have a UIView subclass that draws a circle whose radius changes (with nice bouncy animations). The view is deciding the size of the circle.

I want this UIView subclass

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-30 09:17

    Well for Swift 4/3 this works and I think this is best practise. If you have a UIView with a UILabel in it and the UIView adapts the frame from the UILabel, use this:

    self.theUILabel.text = "text update"
    UIView.animate(withDuration: 5.0, animations: {
       self.theUIView.layoutIfNeeded()
    })
    

    The normal self.view.layoutIfNeeded() will work most of the time as well.

提交回复
热议问题