如何在标题更改时停止不需要的 UIButton 动画? [英] How to stop unwanted UIButton animation on title change?
本文介绍了如何在标题更改时停止不需要的 UIButton 动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 iOS 7 中,我的 UIButton 标题在错误的时间进出动画 - 晚了.这个问题在iOS 6上不会出现.我只是在使用:
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 forState:UIControlStateNormal];
我希望这会立即发生并且没有空白帧.这种眨眼会特别分散注意力,并且会分散人们对其他动画的注意力.
I would prefer this happens instantly and without a blank frame. This blink is especially distracting and draws attention away from other animations.
推荐答案
这适用于自定义按钮:
[UIView setAnimationsEnabled:NO];
[_button setTitle:@"title" forState:UIControlStateNormal];
[UIView setAnimationsEnabled:YES];
对于系统按钮,您需要在重新启用动画之前添加它(谢谢@Klaas):
For system buttons you need to add this before re-enabling animations (thank you @Klaas):
[_button layoutIfNeeded];
这篇关于如何在标题更改时停止不需要的 UIButton 动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文