I want to apply animation on UILabel text. I write the code to increase font size in animation block but animation is not applied.
[UIView beginAnimations:nil context:nil/*contextPoint*/];
monthsOnBoard.font=[UIFont fontWithName:@"digital-7" size:150];
daysOnBoard.font=[UIFont fontWithName:@"digital-7" size:150];
hoursOnBoard.font=[UIFont fontWithName:@"digital-7" size:100];
minutesOnBoard.font=[UIFont fontWithName:@"digital-7" size:100];
secondsOnBoard.font=[UIFont fontWithName:@"digital-7" size:100];
[UIView setAnimationDelegate:self];
[UIView setAnimationDelay:0.5];
[UIView setAnimationDuration:1];
[UIView setAnimationRepeatCount:4];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView commitAnimations];
The font of a UIView is not an animatable property. You should use transforms instead.
[UIView beginAnimations:nil context:nil/*contextPoint*/];
monthsOnBoard.transform = CGAffineTransformMakeScale(2.0, 2.0); //increase the size by 2
//etc etc same procedure for the other labels.
[UIView setAnimationDelegate:self];
[UIView setAnimationDelay:0.5];
[UIView setAnimationDuration:1];
[UIView setAnimationRepeatCount:4];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView commitAnimations];
similarly, you can play with the values in CGAffineTransformMakeScale(x, y);
- x is the horizontal scale constant and y is the vertical one. Enjoy!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With