Avoiding making a UIButton transparent/see-through when disabling it(禁用 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.
推荐答案
试试userInteractionEnabled
属性:
button.userInteractionEnabled = NO;
这篇关于禁用 UIButton 时避免使其透明/透视的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:禁用 UIButton 时避免使其透明/透视


基础教程推荐
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01