项目作者: aditya5045

项目描述 :
Custom Radio Button for IOS (Swift).
高级语言: Swift
项目地址: git://github.com/aditya5045/ASRadioButton.git
创建时间: 2019-07-15T08:05:16Z
项目社区:https://github.com/aditya5045/ASRadioButton

开源协议:

下载


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:

    1. @IBOutlet weak var maleRadioButton: ASRadioButton!
    2. @IBOultet weak var femaleRadioButton: ASRadioButton!
  3. Create a method:

    1. fileprivate func setButtonInterface(_ sender: ASRadioButton, check: Bool) {
    2. sender.isChecked = check
    3. sender.changeFillState()
    4. }
  4. Create a common action for the genderButton and attach to both button:
    1. @IBAction func genderButtonTapped(_ sender: VURadioButton) {
    2. if sender == maleRadioButton {
    3. setButtonInterface(maleRadioButton, check: true)
    4. setButtonInterface(femaleRadioButton, check: false)
    5. }else {
    6. setButtonInterface(maleRadioButton, check: false)
    7. setButtonInterface(femaleRadioButton, check: true)
    8. }
    9. }