Ios 减少已设置动画的视图和子视图

Ios 减少已设置动画的视图和子视图,ios,objective-c,animation,resize,Ios,Objective C,Animation,Resize,我目前正在尝试制作一个ui视图,其中包含一些ui标签,并将其动画化为新的大小。但这样做,我很难理解我的观点到底发生了什么。我读了一些关于它的其他帖子,但我仍然不清楚到底发生了什么 在我的按钮中,我添加了一些仅为右约束大小两倍的内容: [superView layoutIfNeeded]; rightConst.constant *= 2; [UIView animateWithDuration:3 animations:^{ [superView layoutIfNeeded

我目前正在尝试制作一个
ui视图
,其中包含一些
ui标签
,并将其动画化为新的大小。但这样做,我很难理解我的观点到底发生了什么。我读了一些关于它的其他帖子,但我仍然不清楚到底发生了什么

在我的按钮中,我添加了一些仅为右约束大小两倍的内容:

[superView layoutIfNeeded];
rightConst.constant *= 2;
[UIView animateWithDuration:3
animations:^{
        [superView layoutIfNeeded];
    } completion:nil];
superView是我想要设置动画的视图,并向右约束

但这样做,动画开始,但它实际上是来自左侧。我不明白这部分。我的目标是只对视图的右侧设置动画,以显示调整大小,可能还有视图的底部,但左上角应该是固定的

谢谢。

如本文所述,如果您调用
[aView layoutSubviews]
,则
aView
的子视图的布局是强制的,但
aView
的布局本身不是强制的

您需要调用要设置动画的视图的superview的LayoutSubView。在本例中,两个标签的superview的superview

解决方案就在这里

UIView *theView;
// theView is the superview of the superview of the two labels.
theView = superView.superview;
[theView layoutIfNeeded];
rightConst.constant *= 2;
[UIView animateWithDuration:3
    animations:^{
        [theView layoutIfNeeded];
    } completion:nil];

显示您在标签上应用了哪些约束?我添加了它:已更新