GithubHelp home page GithubHelp logo

bkbarry / simplecheckbox Goto Github PK

View Code? Open in Web Editor NEW

This project forked from beaunouvelle/simplecheckbox

0.0 0.0 0.0 154 KB

A simple Checkbox

License: MIT License

Swift 83.79% Objective-C 4.79% Ruby 11.41%

simplecheckbox's Introduction

SimpleCheckbox aims to accomplish what other ios checkbox controls haven't. To be simple. There's no animations, no IBDesignable to slow down interface builder, and no performance heavy draw methods.

๐ŸŽ‰ Features

๐Ÿ“’ Documentation

โš–๏ธ Carefully tuned default values.

โœ… Requirements

  • Xcode 11
  • iOS 10+
  • Swift 5.1

๐Ÿ‘จโ€๐Ÿ’ป Installation

Manual

Just drag Checkbox.swift into your project to start using it.

Carthage

  • Add github "BeauNouvelle/SimpleCheckbox" to your Cartfile.

You can learn more about Carthage and get help setting it up here.

Cocoapods

  • Add pod SimpleCheckbox to your pod file.
  • Add import SimpleCheckbox to the top of your files in where you wish to use it.

Swift Package Manager

Would love some help with this one.

๐Ÿ‘ฉโ€๐Ÿณ Usage

You can create a new Checkbox either programatically:

let checkbox = Checkbox(frame: CGRect(x: 50, y: 50, width: 25, height: 25))

Or using interface builder by dragging a UIView into your view controller and assigning its class to Checkbox.

After hooking up an outlet you can begin customization.

๐Ÿ‘ฉโ€๐ŸŽจ Customization

Border

Border Color

checkbox.checkedBorderColor = .blue
checkbox.uncheckedBorderColor = .black

Border Style

checkbox.borderStyle = .circle
checkbox.borderStyle = .square

Checkmark

Checkmark Color

checkbox.checkmarkColor = .blue

Checkmark Style

checkbox.checkmarkStyle = .circle
checkbox.checkmarkStyle = .square
checkbox.checkmarkStyle = .cross
checkbox.checkmarkStyle = .tick

Haptic Feedback

checkbox.useHapticFeedback = true

Events

There are two methods for detecting when a tap event has occured and the isChecked property has changed.

Add Target

checkbox.addTarget(self, action: #selector(checkboxValueChanged(sender:)), for: .valueChanged)

.......

@objc func checkboxValueChanged(sender: Checkbox) {
    print("checkbox value change: \(sender.isChecked)")
}

Closure

checkbox.valueChanged = { (isChecked) in
    print("checkbox is checked: \(isChecked)")
}

Touch Area

Checkboxs can sometimes appear smaller than their UIButton and UISwitch counterparts which can make them difficult to activate.

SimpleCheckbox has a way for you to tune the touch raduis to extend beyond its frame. Setting increasedTouchRadius will increase the touch radius by that amount.

checkbox.increasedTouchRadius = 5 // Default

๐ŸŽฉ Fancy Alternatives

Objective C โ€” BEMCheckbox

Swift โ€” M13Checkbox

Cocoapods

I'm unable to continue supporting cocoapods with this project as I no longer have access the email account that was registered with this pod. All attempts to contact the cocoapods team to claim SimpleCheckbox pod have been ignored.

simplecheckbox's People

Contributors

beaunouvelle avatar ezefranca avatar raven 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.