【发布时间】:2016-07-11 09:07:47
【问题描述】:
我对 UIView 中的 UIButtons 有一个奇怪的问题。视图最初被限制为 0 的高度,我正在使用
UIView.animateWithDuration(0.6, delay: 0, options: UIViewAnimationOptions.CurveEaseInOut, animations: {
heightConstraint!.constant = height
self.view.layoutIfNeeded()
}) { (finished) in
}
这非常有效,除了放置在其中的任何 UIButton 之外,动画视图的所有内容都按预期显示。
按钮的titleLabel 字体大小在动画期间从 0 增加到正确的大小。这些按钮没有什么特别之处;它们设置为 18 的系统字体,相对于 superview 定位。按钮框架是正确的,只是字体大小发生了变化。
我尝试过明确设置adjustsFontSizeToFitWidth 和contentMode,但这些都没有效果。有趣的是,如果我在视图中添加一个普通的UILabel,就可以了。
关于发生了什么有什么建议吗?
【问题讨论】:
标签: ios swift uibutton uiviewanimation ios-autolayout