Coder Social home page Coder Social logo

bemcheckbox's Introduction

BEMCheckBox

Build Status Version License Platform

BEMCheckBox is an open source library making it easy to create beautiful, highly customizable, animated checkboxes for iOS.

Table of Contents

Project Details

Learn more about the BEMCheckBox project, licensing, support etc.

Requirements

  • Requires iOS 7 or later. The sample project is optimized for iOS 9.
  • Requires Automatic Reference Counting (ARC).
  • Optimized for ARM64 Architecture.

License

See the License. You are free to make changes and use this in either personal or commercial projects. Attribution is not required, but highly appreciated. A little "Thanks!" (or something to that affect) is always welcome. If you use BEMCheckBox in your app, please let us know!

Support

Gitter chat
Join us on Gitter if you need any help or want to talk about the project.

Sample App

The iOS Sample App included with this project demonstrates one way to correctly setup and use BEMCheckBox. It also offers the possibility to customize the checkbox within the app.

Getting Started

It only takes a few simple steps to install and setup BEMCheckBox to your project.

###Installation The easiest way to install BEMCheckBox is to use CocoaPods. To do so, simply add the following line to your Podfile:

pod 'BEMCheckBox'

The other way to install BEMCheckBox, is to drag and drop the Classes folder into your Xcode project. When you do so, make sure to check the "Copy items into destination group's folder" box.

Setup

Setting up BEMCheckBox to your project couldn't be more simple. It is modeled after UISwitch. In fact, you could just replace instances of UISwitch by BEMCheckBox in your project!
Here are the steps to follow to get everything up and running:

  1. Import "BEMCheckBox.h" to the header of your view controller:
#import "BEMCheckBox.h"
  1. BEMCheckBox can either be initialized programatically (through code) or with Interface Builder (Storyboard file). Use the method that makes the most sense for your project.

Programmatical Initialization
Just add the following code to your implementation (usually in the viewDidLoad method of your View Controller).

BEMCheckBox *myCheckBox = [[BEMCheckBox alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
[self.view addSubview:myCheckBox];

Interface Builder Initialization
1 - Drag a UIView to your UIViewController.
2 - Change the class of the new UIView to BEMCheckBox.
3 - Select the BEMCheckBox and open the Attributes Inspector. Most of the customizable properties can easily be set from the Attributes Inspector. The Sample App demonstrates this capability.

Documentation

All of the methods and properties available for BEMCheckBox are documented below.

Enabling / Disabling the Checkbox

The on Property

Just like UISwitch, BEMCheckBox provides the boolean property on that allows you to retrieve and set (without animation) a value determining wether the BEMCheckBox object is on or off. Defaults to NO.
Example usage:

self.myCheckBox.on = YES;
setOn:animated:

Just like UISwitch, BEMCheckBox provides an instance method setOn:animated: that sets the state of the checkbox to On or Off, optionally animating the transition.
Example usage:

[self.myCheckBox setOn:YES animated:YES];

Reloading

The instance method reload lets you redraw the entire checkbox, keeping the current on value.
Example usage:

[self.myCheckBox reload]

Customization

BEMCheckBox is exclusively customizable though properties.
The following diagram provides a good overview:

Apparence Properties

lineWidth - CGFloat
The width of the lines of the check mark and box. Defaults to 2.0.

`hideBox` - BOOL BOOL to control if the box should be hidden or not. Setting this property to `YES` will basically turn the checkbox into a check mark. Defaults to `NO`.

boxType - BEMBoxType
The type of box to use. See BEMBoxType for possible values. Defaults to BEMBoxTypeCircle.

tintColor - UIColor
The color of the box when the checkbox is Off.

onCheckColor - UIColor
The color of the check mark when it is On.

onFillColor - UIColor
The color of the inside of the box when it is On.

onTintColor - UIColor
The color of the line around the box when it is On.

Animations

animationDuration - CGFloat
The duration in seconds of the animations. Defaults to 0.5.

onAnimationType - BEMAnimationType
The type of animation to use when the checkbox gets checked. Defaults to BEMAnimationTypeStroke. See BEMAnimationType bellow for possible values.

offAnimationType - BEMAnimationType
The type of animation to use when the checkbox gets unchecked. Defaults to BEMAnimationTypeStroke. See BEMAnimationType bellow for possible values.

BEMAnimationType
The possible values for onAnimationType and offAnimationType.

  • BEMAnimationTypeStroke

  • BEMAnimationTypeFill

  • BEMAnimationTypeBounce

  • BEMAnimationTypeFlat

  • BEMAnimationTypeOneStroke

  • BEMAnimationTypeFade

bemcheckbox's People

Contributors

boris-em 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.