Animating UILabel size decrease

后端 未结 3 1372
无人及你
无人及你 2020-12-19 04:01

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

<         


        
3条回答
  •  长情又很酷
    2020-12-19 04:43

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

    "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

    Try something like:

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

提交回复
热议问题