Latest 0.0.4
License MIT
Platforms ios 10.0
Frameworks UIKit

Written with StackEdit.


A grouped buttons supporting multiple/radio selection and automatic layout by building with swift. for React Native.

Demo (captured by GIPHY CAPTURE)



Edit your podfile

pod 'selectmultiplebuttons', '~> 0.0.4'

View frames hierarchy

enter image description here


You must adopt the SelectMultipleButtonsDelegate protocol. The protocol likes UITableViewDelegate and UITableDatasource, providing information that SelectMultipleButtons need to construct buttons and manage button selection…

// how many buttons are returned

func numberOf(selectMultipleButtons: SelectMultipleButtons) -> Int

// button returned that is at which index

func buttonOf(selectMultipleButtons: SelectMultipleButtons, atIndex index: Int) -> UIButton

//set maximumNumber selected

//default you can select all buttons

//if you set the value is 1, the selectmultiplebuttons will present radio selecting

@objc optional func maximumNumberSelectedOf(selectMultipleButtons: SelectMultipleButtons) -> Int

//config, containnig the blow items

//edge’s space (top, leading, bottom, trailling)

//between space (vertical space and horizontal space between buttons)

func styleConfigOf(selectMultipleButtons: SelectMultipleButtons) -> StyleConfig

//button’s singeltap event

@objc optional func didSingleTapOf(selectMultipleButtons: SelectMultipleButtons, atIndex index: Int) -> Void

//indexes selected and changed event

@objc optional func indexesSelectedOf(selectMultipleButtons: SelectMultipleButtons, didChange indexes: [Int]) -> Void

code snap

Import modules

import selectmultiplebuttons

Init a selectMultipleButtons

//width is the maxwidth for SelectMultipleButtons view

//no care height, after performing SelectMultipleButtons.load(), the height is calced automaticly.

// you must perform SelectMultipleButtons.load() befor adding it to parent view.

let selectMultipleButtons1 = SelectMultipleButtons.init(frame: CGRect.init(x: 0, y: tip1.frame.origin.y + tip1.frame.height, width: view.frame.width, height: 0))
selectMultipleButtons1.delegate = self

Conform required protocol

func numberOf(selectMultipleButtons: SelectMultipleButtons) -> Int {
    return  buttonTitleArray1.count

func buttonOf(selectMultipleButtons: SelectMultipleButtons, atIndex index: Int) -> UIButton {
    let button = UIButton.init()
    button.setTitle(buttonTitleArray1[index], for: .normal)
    //set none selected state
    button.setTitleColor(.lightGray, for: .normal)
    button.setBackgroundColor(.groupTableViewBackground, for: .normal)
    //set selected state
    button.setTitleColor(.white, for: .selected)
    button.setBackgroundColor(UIColor.init(red: 0x3B/0xFF, green: 0x67/0xFF, blue: 0xBC/0xFF, alpha: 1), for: .selected)
    //default button is selected
    button.isSelected = true
    return button

func styleConfigOf(selectMultipleButtons: SelectMultipleButtons) -> StyleConfig {
    let edgeSpace = EdgeSpace.init(top: 10, leading: 10, bottom: 10, trailling: 10)
    let betweenSpace = BetweenSpace.init(horizontalSpace: 5, verticalSpace: 5)
    return StyleConfig.init(edgeSpace: edgeSpace, betweenSpace: betweenSpace, systemFontSize: 18)


selectmultiplebuttons is MIT licensed.

Latest podspec

    "name": "selectmultiplebuttons",
    "version": "0.0.4",
    "summary": "A grouped buttons supporting multiple/radio selection and automatic layout.",
    "description": "A grouped buttons supporting multiple/radio selection and automatic layout. tag",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Young": "[email protected]"
    "swift_version": "4.0",
    "platforms": {
        "ios": "10.0"
    "source": {
        "git": "",
        "tag": "0.0.4"
    "source_files": [
    "frameworks": "UIKit"

Pin It on Pinterest

Share This