Giter VIP home page Giter VIP logo

dlradiobutton's Introduction

DLRadioButton

Version License Platform

Preview

screenshot1screenshot2

Usage

####To run the example project, clone the repo, and run pod install from the Example directory first.

####To use this Pod from interface builder:

  • Put some UIButtons onto a View
  • Change the UIButtons' type to "custom"

change UIButton Type

  • Set the UIButtons' class to "DLRadioButton"

change UIButton Class

  • Set "otherButtons" outlet

set otherButtons outlet

####To use this Pod from code:

#import "DLRadioButton.h"

// set up button icons
for (DLRadioButton *radioButton in self.topRadioButtons) {
    radioButton.ButtonIcon = [UIImage imageNamed:@"RadioButton"];
    radioButton.ButtonIconSelected = [UIImage imageNamed:@"RadioButtonSelected"];
}

// programmatically add buttons

// first button
DLRadioButton *firstRadioButton = [[DLRadioButton alloc] initWithFrame:CGRectMake(30, 200, self.view.frame.size.width - 60, 30)];
firstRadioButton.buttonSideLength = 30;
[firstRadioButton setTitle:@"Red Button" forState:UIControlStateNormal];
[firstRadioButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
firstRadioButton.circleColor = [UIColor redColor];
firstRadioButton.indicatorColor = [UIColor redColor];
firstRadioButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;

// other buttons
[self.view addSubview:firstRadioButton];
NSArray *colorNames = @[@"Orange", @"Green", @"Cyon", @"Blue", @"Purple"];
NSArray *buttonColors = @[[UIColor orangeColor], [UIColor greenColor], [UIColor cyanColor], [UIColor blueColor], [UIColor purpleColor]];
NSInteger i = 0;
NSMutableArray *otherButtons = [NSMutableArray new];
for (UIColor *buttonColor in buttonColors) {
    // customize button
    DLRadioButton *radioButton = [[DLRadioButton alloc] initWithFrame:CGRectMake(30, 240+40*i, self.view.frame.size.width - 60, 30)];
    radioButton.buttonSideLength = 30;
    [radioButton setTitle:[colorNames[i] stringByAppendingString:@" Button"] forState:UIControlStateNormal];
    [radioButton setTitleColor:buttonColor forState:UIControlStateNormal];
    radioButton.circleColor = buttonColor;
    radioButton.indicatorColor = buttonColor;
    if (i > 1) {
        // put icon on the right side
        radioButton.iconOnRight = YES;
        radioButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    } else {
        radioButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    }
    [otherButtons addObject:radioButton];
    [self.view addSubview:radioButton];
    i++;
}

firstRadioButton.otherButtons = otherButtons;

####To customize DLRadiobutton:

There are a bunch of properties that you can set for your Radio Button, please use the following picture for reference: DLRadioButton

Requirements

ARC

DLRadioButton is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "DLRadioButton"

Author

Xingruo Liu, [email protected]

License

DLRadioButton is available under the MIT license. See the LICENSE file for more info.

dlradiobutton's People

Contributors

arrnas avatar davydliu avatar

Watchers

 avatar

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.