在自动布局之前,我通过将框架设置为animateWithDuration
以上来动画背景的高度。使用自动布局快速动画UIView高度
func setUpBackground() {
self.backgroundView.frame = CGRect(x: 0, y: 0, width: 320, height: 10)
self.backgroundView.backgroundColor = UIColorFromRGB(0x2d2d2d).CGColor
}
func AnimateBackgroundHeight() {
UIView.animateWithDuration(0.5, animations: {
self.backgroundView.frame = CGRect(x: 0, y: 0, width: 320, height: 600)
})
}
我将我的项目自动布局后,我注意到,出现动画,但后台的高度弹回后,原来的大小/风格(Interface Builder中设置)。我读到,自动布局打开时,约束将覆盖UIView
尺寸CGRect
。
因此,我想知道如何去实现与自动布局ON相同的高度变化动画效果。
啊我明白了!这很好。非常感谢。 – Poyi 2015-03-25 06:06:04
omg .. layoutIfNeeded()做了诡计...我错过了它 – 2017-05-24 04:22:25