LisonFan LisonFan - 1 month ago 8
iOS Question

About 'beginAnimations' and 'commitAnimations'

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?

Answer

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);
}];