lundi 13 février 2017

How to make custom uibutton darker when pressed in cg?

Vote count: 0

i need to make my custom buttom which is made in cg to be darker when user pressed it, just like original uibutton highlighted state. I came up with making alpha 50% but then background view is visible and i don't want that. Here is my code for that:

    func unhighlightButton(){
    self.color = someColor
    self.setNeedsDisplay()

}

override var isHighlighted: Bool {
    didSet{
        if isHighlighted == true{
            self.gradientColor = someColor.withAlphaComponent(0.5)
            self.setNeedsDisplay()
            self.perform(#selector(unhighlightButton), with: nil, afterDelay: 0.1)
        }
    }
}

asked 35 secs ago

Let's block ads! (Why?)



How to make custom uibutton darker when pressed in cg?

Aucun commentaire:

Enregistrer un commentaire