动画的UILabel尺寸的减小 [英] Animating UILabel size decrease

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

问题描述

在增加标签的高度,一切都很好,光滑。 decreaseing时,标签会立即改变大小,然后用动画重新定位。

When increasing the height of label, everything is fine and smooth. When decreaseing, the label is instantly changing the size then repositioning with animation.

@interface
@property (nonatomic, retain) IBOutlet UILabel *explanationLabel;

@implementation
CGRect frmExpl = explanationLabel.frame;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.75];

frmExpl.size.height -= height;
explanationLabel.frame = frmExpl;

[UIView commitAnimations];  

我试着UIView的,当然更换的UILabel没有与UIView的没有这样的问题。

I've tried replacing UILabel with UIView and of course there is no such problem with UIView.

有动画的UILabel大小减小任何特殊的方式?

Is there any special way to animate UILabel size decrease?

下面是一个最小的项目展示中描述的问题。 下载

Here is a minimal project demonstrating the issue described. Download

推荐答案

我觉得你是想改变的是边界,而不是框架。从文档:

I think what you are wanting to change is the bounds, rather than the frame. From the docs:

的边界矩形来确定该视图的坐标系中的原点和规模其框架矩形内并在点处测量。设置该属性相应地改变帧属性的值。 - UIView类; bounds属性

"The bounds rectangle determines the origin and scale in the view’s coordinate system within its frame rectangle and is measured in points. Setting this property changes the value of the frame property accordingly." - UIView Class; bounds property

尝试是这样的:

- (void)animate:(id)sender
{
    ...
    CGRect newBounds = testLabel.bounds;
    newBounds.size.height += 50;
    testLabel.bounds = newBounds;
    ...
}

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

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