Search code examples
iosobjective-cuilabelcore-animation

How can I animate the size of UILabel or UITextField text?


I have a UITextfield in a UIView that contains some default text. I want to animate the scaling of this textField (along with the parent UIView) %300, and later back down to 100%.

How do I do this? It seems everything I've found involves a hacky image capture and a CGAffineTransformMakeScale.

I've spent way to much time searching SO for this, either it's difficult and/or costly to do or utterly trival to implement. I wouldn't be surprised if it's the latter. :)


Solution

  • You don't have to capture the image from the view, you can simply use scale transform on your label using the following code

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

    But the only problem with this approach is that the text might not appear crisp.

    If you want the scaling of your UILabel to be crisp than I suggest you try core text framework. This will definitely help you in achieving your goal.

    A tutorial for the same can be found here.