动画的UILabel的框架顺利 [英] Animating Frame of UILabel smoothly

查看:126
本文介绍了动画的UILabel的框架顺利的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图找出一个体面的方式顺利动画上一个UILabel帧大小的变化,没有一个奇怪的开始跳重绘。什么默认情况是,当我做这样的事情:

I've been trying to figure out a decent way to smoothly animate a frame size change on a UILabel, without a weird starting jump redraw. What happens by default is that when I do something like this:

// Assume myLabel frame starts as (0, 0, 100, 200) 
[UIView beginAnimations:@"myAnim" context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:1.0];
myLabel.frame = CGRectMake(0.0, 0.0, 50, 100);
[UIView commitAnimations];

我得到一个流畅的动画与标签,然而,它做它的方式是,它需要重绘图像层为标签的目标规模和口延伸,以适应当前的则内容动画目的地正确。这与在文本显示一个非常奇怪的跳跃结束。以下是显示了pre-动画看两张图片,然后就在动画开始后:

I get a smooth animation with the label, however the way that it does it is that it takes the redrawn image layer for the destination size of the label and streches the content to fit the current then animates to the destination rect. This ends up with a very bizarre jump in the text display. Here are two images showing the pre-animation look, and then just after the animation starts:

pre-动画结果

Pre-Animation

后动画结果

Post-Animation

我曾尝试使用刚刚层动画,但我仍然得到同样的问题。

I have tried to use just the layer to animate this, but I still get the same issues.

所以,问题是,我该如何避免这种情况?

So the question is, how can I avoid this?

感谢您的帮助,结果
斯科特

Thanks for any help,
Scott

推荐答案

万岁回答了两年的死的问题,但我找到了答案。无论是在界面生成器或code,标签的 contentMode 属性更改。你似乎对 scaleToFill 设置;尝试离开右键

Hooray for answering a two-year dead question, but I found the answer. Either in Interface Builder or in code, change the contentMode property of the label. Yours seems to be set on scaleToFill; try left or right.

这篇关于动画的UILabel的框架顺利的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆