Skip to content

Latest commit

 

History

History
32 lines (28 loc) · 943 Bytes

README.md

File metadata and controls

32 lines (28 loc) · 943 Bytes

ASRadioButton

Custom Radio Button for IOS (Swift).

Implementation:

  1. Drag and Drop ASRadioButton.swift file in the project.
  2. Create an Outlet for the Radio Button:
    @IBOutlet weak var maleRadioButton: ASRadioButton!
    @IBOultet weak var femaleRadioButton: ASRadioButton!
  1. Create a method:
    fileprivate func setButtonInterface(_ sender: ASRadioButton, check: Bool) {
        sender.isChecked = check
        sender.changeFillState()
    }
  1. Create a common action for the genderButton and attach to both button:
  @IBAction func genderButtonTapped(_ sender: VURadioButton) {
        if sender == maleRadioButton {
            setButtonInterface(maleRadioButton, check: true)
            setButtonInterface(femaleRadioButton, check: false)
        }else {
            setButtonInterface(maleRadioButton, check: false)
            setButtonInterface(femaleRadioButton, check: true)
        }
   }