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
I think what you are wanting to change is the bounds, rather than the frame. From the docs:
Try something like:
The issue is that the UILabel redraws itself as soon as its size changes. (It can't redraw every frame of the animation because text rendering happens on the CPU, not the GPU where UIView animations run.) You can keep it from redrawing by changing the label's contentMode property to, e.g., UIViewContentModeCenter.
Use a
CGAffineTransform
to do this.