Skip to content

Instantly share code, notes, and snippets.

@rajuashok
Last active August 7, 2020 16:04
Show Gist options
  • Save rajuashok/c7fc56a10068bbaf2b0c232ed13cb518 to your computer and use it in GitHub Desktop.
Save rajuashok/c7fc56a10068bbaf2b0c232ed13cb518 to your computer and use it in GitHub Desktop.
Example of RadioButton in use
class MyView: UIView, RadioButtonDelegate {
let radioButton = RadioButton()
override init(frame: CGRect) {
super.init(frame: frame)
radioButton.delegate = self
radioButton.checkedView = UIImageView.radioOn()
radioBUtton.uncheckedView = UIImageView.radioOff()
}
.
.
.
func onClick(_ sender: UIView) {
guard let sender = sender as? RadioButton else {
return
}
radioButton.isChecked = !radioButton.isChecked
// Take note of which radioButtons are selected if you need here.
// Possibly unselect the other radio buttons if this is a single choice question for e.g.
}
}
@rajuashok
Copy link
Author

To be clear I don't have a project for this gist. I just made this as an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment