Increase and decrease text size UILabel

I want to apply animation in UILabel text. I am writing code to increase the font size in the animation block, but the animation does not apply.

[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]; 
+4
source share
2 answers

The UIView font is not an animated property. You should use conversions 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 values ​​in CGAffineTransformMakeScale(x, y); - x is a constant of horizontal scale, and y is a vertical one. Enjoy !!

+10
source

it can help you

  monthsOnBoard.transform = CGAffineTransformScale(monthsOnBoard.transform, 1, 1); [UIView beginAnimations:nil context:nil/*contextPoint*/]; monthsOnBoard.transform = CGAffineTransformScale(monthsOnBoard.transform, 4, 4); [UIView setAnimationDelegate:self]; [UIView setAnimationDelay:0.5]; [UIView setAnimationDuration:1]; [UIView setAnimationRepeatCount:4]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView commitAnimations]; 
+1
source

Source: https://habr.com/ru/post/1413665/


All Articles