简体   繁体   中英

Disable UIButton highlighting in Storyboard and Swift 2

I am trying to disable Highlighting on a UIButton setup in Storyboard. I am using Swift on Xcode 7.1. I have the button set to Custom, and I have tried everything I can think of, and it is still highlighting. Here is another question for Objective-C, and I have tried everything on it, even the Storyboard image name white space idea.

The button is hooked up correctly.

How do you disable highlighting? Is it a bug in Xcode?

I guess you mean you don't want the button to appear to change when it's tapped. One way to do it is by creating a subclass of UIButton that refuses to become highlighted:

class NonHighlightingButton: UIButton {
    override var highlighted: Bool {
        set { }
        get { return super.highlighted }
    }
}

Then, in your storyboard, set the custom class of your button to NonHighlightingButton :

身份检查员

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM