【问题标题】:How to disable UIButton highlight when pressed in a nib file?在 nib 文件中按下时如何禁用 UIButton 突出显示?
【发布时间】:2018-09-03 07:22:09
【问题描述】:

我在 nib 文件的 UIView 中有一个 UIButton,我想在按下按钮时禁用突出显示。

但是,在 Interface Builder 中为按钮取消选中框(对于所有状态)“突出显示调整图像”不会删除突出显示。

我还尝试在 @IBAction 中以编程方式禁用突出显示:

@IBAction func myButtonTapped(_ sender: UIButton) {
    sender.adjustsImageWhenHighlighted = false
}

但是当按钮被按下时,高亮仍然在这里。

以上方法均无效时如何禁用高亮?

【问题讨论】:

  • 确保您的UIButton 类型设置为自定义。
  • 这解决了这个问题。谢谢!

标签: ios swift uibutton uikit nib


【解决方案1】:

要使用adjustsImageWhenHighlighted,您的UIButton 类型应设置为自定义。

【讨论】:

    猜你喜欢
    • 2017-05-15
    • 2011-09-14
    • 2013-07-05
    • 2020-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-23
    • 1970-01-01
    相关资源
    最近更新 更多