如何在标题更改时阻止不需要的UIButton动画? [英] How to stop unwanted UIButton animation on title change?

查看:102
本文介绍了如何在标题更改时阻止不需要的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆