我正在尝试移动标签并调整其大小,但发生的情况是标签立即调整大小然后移动到位。我首先简单地尝试了注释掉的 lbl.frame 行。接下来我发现了这个问题:
并添加了除 contentMode 之外的所有其他代码。这做了我想要的,但是标签的字体没有随着标签的缩小而向下调整。(我勾选调整以适应 xib )。最后添加 contentMode 线给了我与原始框架线相同的结果 - 首先立即收缩它们为移动设置动画。
lbl.contentMode = UIViewContentModeRedraw;
[UIView animateWithDuration:1.0 delay:0.0
options:(UIViewAnimationOptionAllowUserInteraction)
animations:^{
//lbl.frame = CGRectMake(x, mStartingLine.frame.origin.y+mStartingLine.frame.size.height, 100, 100);
CGRect theBounds = lbl.bounds;
CGPoint theCenter = lbl.center;
theBounds.size.height = 100;
theBounds.size.width = 100;
theCenter.y = mStartingLine.frame.origin.y+mStartingLine.frame.size.height+50;
theCenter.x = x;
lbl.bounds = theBounds;
lbl.center = theCenter;
}
completion:nil
];