如何删除已丢弃的UIButton的灰色外观 [英] How to remove the greyed out look of a disbled UIButton

查看:129
本文介绍了如何删除已丢弃的UIButton的灰色外观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIButton,当它处于禁用状态时,我希望它看起来完全相同,就像它处于Normal状态一样。现在它有一个略带灰色的外观。

I've got a UIButton that i want to look exactly the same when it's in its disabled state as when it's in its Normal state. Right now it has a slight greyed out look to it.

推荐答案

不要使用enabled属性或setEnabled:NO方法,而是使用:

Do not use enabled property or setEnabled:NO method, instead use:

[myButton setUserInteractionEnabled:NO];

这会阻止按钮被触摸,但不会改变他的外表!

That would prevent the button for being touched, but without changing his looks!

另一种方式是,如果您的按钮是自定义按钮并且有图像:

The other way is if your button is a custom button and has an image:

[button setImage:someImage forState:UIControlStateNormal];
[button setImage:someImage forState:UIControlStateDisabled];
[button setEnabled:NO];

这篇关于如何删除已丢弃的UIButton的灰色外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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