views:

47

answers:

1

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];  

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

Is there any special way to animate UILabel size decrease?

Here is a minimal project demonstrating the issue described. Download

A: 

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;
    ...
}
MattLeff
Increasing bounds does change frame, but the frame remains same on the screen. Decreasing bounds works. But this is not solution, since I need both to increase and decrease. I suspect this is a bug in framework.
Michael
True, it is probably a bug. Could you change your view hierarchy to have a UIView with the blue background and then a fixed-size UILabel that merely has its struts and springs set to float in the middle of the UIView. Given that the UIView animates correctly that might be a solution.
MattLeff