Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UILabel animate the width

Tags:

ios

How do we go about animating the UILabel's width so that it increases and decreases in width only using UIView animateWithDuration

Thank you for your help (at this point i'm so frustrated as I've been trying to do so but it does not work)

like image 580
inforeqd Avatar asked Dec 14 '25 06:12

inforeqd


1 Answers

You can set the frame of the UILabel inside the UIView animation block. Something like this:

CGRect originalFrame = self.address.frame;

[UIView animateWithDuration:0.3
                 animations:^{
    self.myLabel.frame = CGRectMake(0, 0, 100, 100);
}
                 completion:^(BOOL finished) {
                     // use similar UIView animation to resize back to original
                 }];

Obviously the dimensions you feed in will depend on your app, and may be calculated based on the content.

like image 67
Stew Avatar answered Dec 15 '25 23:12

Stew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!