0

I added in the button click event:

[UIView beginAnimations:nil context:nil];
sender.titleLabel.font = [UIFont systemFontOfSize:18];
[UIView commitAnimations];

The animation is not working. But if I remove [UIView commitAnimations];, the animation works. Why?

If I don't add [UIView commitAnimations];, what will happen?

Erik Godard
  • 5,930
  • 6
  • 30
  • 33
LisonFan
  • 53
  • 5
  • Those methods are deprecated. Use the block-based version of `UIView` animations. See http://stackoverflow.com/questions/11723545/use-of-beginanimations-discouraged – rmaddy Oct 27 '16 at 03:18
  • Thank you for your reply, but '[UIView animateWithDuration: <# (NSTimeInterval) #> animations: <# ^ (void) animations #> completion: <# ^ (BOOL finished) completion #>]' Also does not work – LisonFan Oct 27 '16 at 03:27
  • `UILabel font` is not an animatable property. See http://stackoverflow.com/questions/14494566/animating-uilabel-font-size-change?s=1|1.6166 – rmaddy Oct 27 '16 at 03:30
  • Thank you very much for your reply,My problem is solved – LisonFan Oct 27 '16 at 04:20

1 Answers1

0

Why you are not using this for view animations?

[UIView animateWithDuration:1.0 animations:^{
    // place your animations code here
}];

Note: please visit this url and see the section What can be animated. Only few properties can be used for animations

https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/AnimatingViews/AnimatingViews.html

Try this, it will help. In the example below, viewObject may be label in your case.

[UIView animateWithDuration:1.0 animations:^{
    viewObject.transform = CGAffineTransformMakeScale(1.5, 1.5);
}];
KGen
  • 50
  • 3