The gist demonstrates how to add a custom UIControlState
and set image for that state to a custom UIButton
.
Last active
May 26, 2020 11:50
-
-
Save T-Pham/82e8f4fe9676cef4923aa05fff27f6cb to your computer and use it in GitHub Desktop.
Custom UIControlState
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let myButton = MyButton() | |
myButton.setImage(UIImage(named: "ErrorCross"), forState: .Error) | |
myButton.setImage(UIImage(named: "ErrorCross"), forState: [.Error, .Highlighted]) | |
myButton.setImage(UIImage(named: "ErrorCross"), forState: [.Error, .Selected]) | |
myButton.setImage(UIImage(named: "ErrorCross"), forState: [.Error, .Selected, .Highlighted]) | |
myButton.error = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could do this: