簡體   English   中英

UILabel寬度的動畫減少不會顯示

[英]Animated decrease of a UILabel's width doesn't get displayed

我正在嘗試減少動畫中UILabel的寬度,但寬度會立即改變而不會有任何動畫! 如果我增加寬度,一切正常,你可以看到動畫。

這是我的代碼:

[UIView animateWithDuration:0.5 
                      delay:0.0 
                    options:UIViewAnimationCurveLinear 
                 animations:^ (void){
                       CGRect theNewFrame      = self.titleLabel.frame;
                       theNewFrame.size.width -= 50.0; 
                       self.titleLabel.frame   = theNewFrame;
                 }
                 completion:^(BOOL finished){}];

所以,如果我改變

theNewFrame.size.width -= 50.0;

theNewFrame.size.width += 50.0;

你可以看到標簽增加。 但減少寬度不會工作!

我對此行為沒有任何解釋。 這是一個錯誤嗎?

謝謝你的回答!

在開始動畫之前,嘗試將標簽的contentMode設置為UIViewContentModeCenter

self.titleLabel.contentMode = UIViewContentModeCenter;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM