How to stop unwanted UIButton animation on title change?

前端 未结 24 2744
面向向阳花
面向向阳花 2020-11-28 19:07

In iOS 7 my UIButton titles are animating in and out at the wrong time - late. This problem does not appear on iOS 6. I\'m just using:

[self setTitle:text fo         


        
24条回答
  •  醉话见心
    2020-11-28 19:43

    This works for custom buttons:

    [UIView setAnimationsEnabled:NO];
    [_button setTitle:@"title" forState:UIControlStateNormal];
    [UIView setAnimationsEnabled:YES];
    

    For system buttons you need to add this before re-enabling animations (thank you @Klaas):

    [_button layoutIfNeeded];
    

提交回复
热议问题