Latest 1.0.0
Homepage https://github.com/nukaten/RadioCheckButton
License MIT
Platforms ios 11.0
Authors

Swift implement radio and check button

Features

  • Multi-line text auto wrap
  • Horizontal & vertical layout
  • Icon and option text size and color customation

DEMO

RadioCheckButton Image

Usage

let options: [String] = ["Lorem Ipsum is simply dummy text", "Lorem Ipsum is simply dummy text", "Lorem Ipsum is simply dummy text"]
let radioButtonGroup = RadioCheckGroupView(frame: .zero, options: options)
radioButtonGroup.radioCheckButtons[1].isSelected = true

When tap one option, you can get its value through delegate method or swift closure as below.

  1. delegate method
    radioButtonGroup.delegate = self
    func didSelected(radioCheckButton: RadioCheckButton) {
    if let mark = radioCheckButton.mark {
        print("mark: (mark)")
    }
    if let text = radioCheckButton.titleLabel.text {
        print("text: (text)")
    }
    }
  2. Or use closure
    checkButtonGroup.selectedBlockHandler = { button in
    print("mark: (String(describing: button.mark)); text:(String(describing: button.titleLabel.text))")
    }

You can also get all the selected options through the selectedValue attribution, which return all the selected RadioCheckButton objects whether you use radioButton or checkButton. eg.

firstGroupValueLabel.text = radioButtonHorizontalGroup.selectedValue.reduce("", { $0 + ($1.mark ?? "") })

For more detail introduction, please refer to the example project

Installation

Cocoapod

pod 'RadioCheckButton', '~> 1.0'

License

MIT

Latest podspec

{
    "name": "RadioCheckButton",
    "version": "1.0.0",
    "summary": "radio and check button implemented by swift",
    "description": "Radio and check button like the ones in html, simple and conveniently to be applied in your project. Any question is welcome in issue board of Github. Enjoy it.ud83cudf7b",
    "homepage": "https://github.com/nukaten/RadioCheckButton",
    "screenshots": "https://github.com/nukaten/RadioCheckButton/blob/master/images/IMG_5858.gif?raw=true",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "sedgwickz": "[email protected]"
    },
    "platforms": {
        "ios": "11.0"
    },
    "swift_version": "4.0",
    "source": {
        "git": "https://github.com/nukaten/RadioCheckButton.git",
        "tag": "1.0.0"
    },
    "source_files": "Sources/*.swift"
}

Pin It on Pinterest

Share This