13

Is there a way to animate a change in the font size of some text. I was thinking to call drawRect from a subclass of UIView and draw the text at different sizes.

MattyG
  • 8,449
  • 6
  • 44
  • 48
prostock
  • 9,327
  • 19
  • 70
  • 118
  • What do you mean saying animate Font size ? What do you want to do ? – Viktor Apoyan May 26 '11 at 07:24
  • E.g. if the font is 20 and he wants to animate it all the way down to 10px. – Tudor Jul 01 '11 at 11:56
  • Possible duplicate of [Can font size of UILabel be changed with smooth animation on iPhone?](http://stackoverflow.com/questions/2098893/can-font-size-of-uilabel-be-changed-with-smooth-animation-on-iphone) – mixel Sep 09 '16 at 15:36

2 Answers2

14

You can animate the transform on any UIView including labels.

[UIView beginAnimations:nil context:nil];
label.transform = CGAffineTransformMakeScale(1.5,1.5);
[UIView commitAnimations];

That will scale the text up to 150%. It may become blocky if you make it too big.

skorulis
  • 4,361
  • 6
  • 32
  • 43
  • Beautiful. Pair this with a drop shadow and it looks like the text is really jumping out at you. It's a neat effect. Thanks for the code skorulis. – zakdances Mar 29 '13 at 20:51
-3

Have you tried this?

[UIView beginAnimations:nil context:self.view];
[UIView setAnimationDuration:0.5];
label.font = [UIFont font...]; //try setting the font and the size you want
[UIView commitAnimations];
Vaibhav Tekam
  • 2,344
  • 3
  • 18
  • 27
  • 2
    This will not work. http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/AnimatingViews/AnimatingViews.html#//apple_ref/doc/uid/TP40009503-CH6-SW1 does not list font as an animatable property. – Klaas Jan 10 '13 at 02:13