1
我試圖移動並調整標籤尺寸,但會發生什麼情況是標籤會立即調整大小然後移動到位置。我首先嚐試了註釋掉的lbl.frame行。接下來,我發現了這樣一個問題:iPad - 如何移動和調整標籤尺寸
How to animate while resizing UIView
並補充其他所有的代碼除了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
];