Change UIButton border color on highlight

后端 未结 6 780
礼貌的吻别
礼貌的吻别 2021-02-03 23:53

I\'ve got a simple custom UIButton, to which I added:

button.layer.bordercolor = [[UIColor blueColor]CGColor];

However, I want to change the .b

6条回答
  •  醉梦人生
    2021-02-04 00:47

    Swift 4 :

    override var isHighlighted: Bool {
        didSet {
            layer.borderColor = isHighlighted ? UIColor.lightGray.cgColor : UIColor.black.cgColor
        }
    }
    

提交回复
热议问题