Swift - UIButton overriding setSelected

后端 未结 4 1645
心在旅途
心在旅途 2020-12-16 09:53

I\'m making a UIButton subclass in Swift to perform custom drawing and animation on selection

What would be the equivalent in Swift of overriding - (void)setSe

4条回答
  •  攒了一身酷
    2020-12-16 10:32

    you'd do it like e.g. this:

    class MyButton : UIButton {
    
        // ...
    
        override var isSelected: Bool {
            willSet(newValue) {
                super.isSelected = newValue;
                // do your own business here...
            }
        }
    
        // ...
    
    }
    

提交回复
热议问题