ielyamani
ielyamani

Reputation: 18581

How to prevent uibutton alpha from going to zero when button tapped in Swift?

The alpha of a UIbutton goes to zero, and it becomes transparent when tapped. Ive added this IBAction

@IBAction func btnTapped(sender: UIButton) {
    sender.highlighted = false
    //...
}

and the UIButton still gets transparent when touched. How to prevent that?

Upvotes: 9

Views: 2543

Answers (2)

iagomr
iagomr

Reputation: 442

Did you try something like:

yourButtonClass.setTitleColor(UIColor.blackColor(), forState: .Highlighted)

Upvotes: 1

FloraL
FloraL

Reputation: 316

I wrestled with this problem and finally fixed it by changing the button type from System to Custom.

Upvotes: 23

Related Questions