Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 451
ielyamani Avatar asked Sep 20 '14 20:09

ielyamani


2 Answers

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

like image 160
FloraL Avatar answered Oct 20 '22 20:10

FloraL


Did you try something like:

yourButtonClass.setTitleColor(UIColor.blackColor(), forState: .Highlighted)
like image 27
iagomr Avatar answered Oct 20 '22 22:10

iagomr