Latest 1.5.0
Homepage https://github.com/BeauNouvelle/SimpleCheckbox
License MIT
Platforms ios 10.0

SimpleCheckbox

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 10
  • iOS 10+
  • Swift 4.2

👨‍💻 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: https://github.com/Carthage/Carthage/

Cocoapods

  • Add pod 'SimpleCheckbox' to your pod file.
  • Don’t forget to import SimpleCheckbox to the top of your files where you wish to use it.

👩‍🍳 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 = { (value) in
    print("checkbox value change: (value)")
}

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.

checkbox.increasedTouchRadius = 5 // Default

🎩 Fancy Alternatives

Objective C — BEMCheckbox

Swift — M13Checkbox

Latest podspec

{
    "name": "SimpleCheckbox",
    "version": "1.5.0",
    "summary": "A simple checkbox.",
    "swift_version": "4.2",
    "description": "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.",
    "homepage": "https://github.com/BeauNouvelle/SimpleCheckbox",
    "screenshots": "https://raw.githubusercontent.com/BeauNouvelle/SimpleCheckbox/master/demo/images/banner.png",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": "Beau Nouvelle",
    "social_media_url": "http://twitter.com/BeauNouvelle",
    "platforms": {
        "ios": "10.0"
    },
    "source": {
        "git": "https://github.com/BeauNouvelle/SimpleCheckbox.git",
        "tag": "1.5.0"
    },
    "source_files": "checkbox/*.{swift}"
}

Pin It on Pinterest

Share This