Git Product home page Git Product logo

pvradiobutton's Introduction

PVRadioButton

Radio Button and Radio Buttons View for iOS apps, Swift

This library allows you to easily add Radio Buttons to your views in two ways.

  1. You can set PVRadioButton class as Custom class to your Buutton, then you can set title, color etc attributes to the button from Attributes Inspector and add those buttons to radio button group. you can have any number of groups.

  2. You can just add a view and set its custom class as PVRadioButtonView, and pass array of button titles to it, it will create list of radio buttons with those titles and place in that view. you can either choose that list to be scrollable or non - scrollable from attribute inspector.

Preview

alt tag

Usage

You can use in two ways as I mentioned above.

First Drag and drop PVRadioButton folder into your app, then

  1. for manually added buttons, You can set PVRadioButton Class as Custom class to your Button and add them to the group as below.

     var radioButtonGroup = PVRadioButtonGroup()
     radioButtonGroup.appendToRadioGroup(radioButtons: [button1,button2])
     radioButtonGroup.appendToRadioGroup(radioButtons: [button3,button4])
    

Here button1, button2 will be in one group and button3,button4 will be added to other group and ViewController has to implement RadioButtonGroupDelegate and set RadioButtonGroupDelegate to itself as below

    radioButtonGroup.delegate = self

and implement following method

    func radioButtonClicked(button: PVRadioButton) {
      print(button.titleLabel?.text ?? "")
    }

Here you will get button which is clicked.

  1. You can just add a view and set its custom class to PVRadioButtonView and create outlet to it and pass array of string i.e. array of button titles as below

     @IBOutlet weak var radioView: PVRadioButtonView!
     radioView.addButtons(radioButtonTitles: ["India","Usa","China","Japan","Argentina","Armenia"])
    

and viewcontroller has to implement RadioButtonViewDelegate and set it to itself as below

    radioView.delegate = self

and implement following method

func radioButtonClickedInView(button: PVRadioButton) {
    print(button.titleLabel?.text ?? "")
}

Here you will get button which is clicked.

If you want it to be scrollable you can set buttonHeight and isScrollable to true from attributes inspector, if you set isScrollable to false it will adjust buttons height so that it all buttons fit in view.you can set various attributes from attributes inspector and change colors and heights according to your requirements.

pvradiobutton's People

Contributors

venkateshyadavp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pvradiobutton's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.