自动布局动画约束不会为子视图设置动画 [英] Autolayout animate constraint does not animate subviews
问题描述
我有一个UIView,其中有一个UILabel作为子视图。
现在,我用动画更改UIView的宽度(更改约束的常量属性)并调用layoutIfIfed in UIView animate ...)
视图的大小正常,但是但是 UILabel(子视图)将字体大小更改为'
根据WWDC 2012会话,如果仅更改了超级视图的常量,则子视图应设置动画。 / p>
UILabel的最小字体比例为0,1,这小于必须调整的字体大小。
我正在通过更改 width
约束来为 UILabel
调整大小设置动画。标签具有 adjustsFontSizeToFitWidth
和 minimumScaleFactor
设置。
I通过将标签的 contentMode
设置为 UIViewContentModeScaleAspectFit
来修复此问题。默认情况下,标签为 UIViewContentModeLeft
。
I have a UIView which has a UILabel as subview in it.
Now I change the width of the UIView with an animation (changing constant property of constraint) and call layoutIfNeeded in UIView animate...)
The view is resizing normal, but the UILabel (subview) changes the font size to the 'end'-size but didn't animate correctly like the uiview.
According to the WWDC 2012 session the subviews should animate if only the constant of the superview gets changed.
The UILabel has a minimum font scale of 0,1 which is less then the font has to resize.
I was struggling animating a UILabel
resize by changing its width
constraint. The label had adjustsFontSizeToFitWidth
and minimumScaleFactor
set.
I fixed it by setting the labels' contentMode
to UIViewContentModeScaleAspectFit
. By default for labels it is UIViewContentModeLeft
.
这篇关于自动布局动画约束不会为子视图设置动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!