[英]iOS 9 Breaks Animations of UILabel
我将我的代码从Swift 1.2迁移到Swift 2.0
在Swift 1.2 / iOS8中,动画才有效。 但是在iOS 9中,它没有动画,Label会立即改变位置,就像从未调用layoutIfNeeded
。
这是我如何为UILabel和UIButton制作动画。 (我正在使用Autolayout,这就是我使用layoutIfNeeded的原因)
使用UILABEL(不工作)
titleLabelTopConstraint.constant = 88;
UIView.animateWithDuration(0.8, delay: 0.38, usingSpringWithDamping: 0.54, initialSpringVelocity: 1, options: UIViewAnimationOptions.CurveLinear, animations: { () -> Void in
self.titleLabel.layoutIfNeeded();
}, completion: nil);
使用UIBUTTON(IT WORKS)
buttonTopConstraint.constant = 88;
UIView.animateWithDuration(0.8, delay: 0.38, usingSpringWithDamping: 0.54, initialSpringVelocity: 1, options: UIViewAnimationOptions.CurveLinear, animations: { () -> Void in
self.button.layoutIfNeeded();
}, completion: nil);
但是如果我在UIButton上做同样的事情,那就行了!
有什么想法吗? 为什么UILabel不可动画?
尝试添加:
self.titleLabel.setNeedsLayout();
在动画块之前。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.