How to stop unwanted UIButton animation on title change?

前端 未结 24 2745
面向向阳花
面向向阳花 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:35

    Maybe generating 2 animations and 2 buttons is a better solution, to avoid the problem that is appearing with animating and changing the text of a button?

    I created a second uibutton and generated 2 animation, this solution works with no hickups.

        _button2.hidden = TRUE;
        _button1.hidden = FALSE;
    
        CGPoint startLocation = CGPointMake(_button1.center.x, button1.center.y - 70);
        CGPoint stopLocation  = CGPointMake(_button2.center.x, button2.center.y- 70);
    
    
        [UIView animateWithDuration:0.3 animations:^{ _button2.center = stopLocation;} completion:^(BOOL finished){_button2.center = stopLocation;}];
        [UIView animateWithDuration:0.3 animations:^{ _button1.center = startLocation;} completion:^(BOOL finished){_button1.center = startLocation;}];
    

提交回复
热议问题