禁用时,避免使UIButton透明/透明 [英] Avoiding making a UIButton transparent/see-through when disabling it

查看:106
本文介绍了禁用时,避免使UIButton透明/透明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想禁用我的UIButton,所以我打电话:

I want to disable my UIButton, so I call:

button.enabled = FALSE;

然而,这使得按钮透视,我可以看到它下面的元素。我不介意它改变颜色,我只是不希望它透明。

However this makes the button see-through and I can see the elements underneath it. I don't mind that it changes colour, I just don't want it to be see-through.

我试过勾选不透明的方框IB中的剪辑子视图,但没有快乐。

I've tried ticking the boxes for 'opaque' and 'clip subviews' in IB, but no joy.

有没有一种简单的方法可以解决这个问题?我想我可以在UIImageView后面放一个相同的按钮图像,但这不是一个优雅的解决方案。

Is there an easy way to fix this? I suppose I could put a UIImageView with the same button image behind it, but it's hardly an elegant solution.

全部谢谢!!

Michael

推荐答案

尝试 userInteractionEnabled property:

Try userInteractionEnabled property:

button.userInteractionEnabled = NO;

这篇关于禁用时,避免使UIButton透明/透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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