Skip to content

light-weight check button in Swift.

License

Notifications You must be signed in to change notification settings

sgr-ksmt/SUCheckButton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SUCheckButton

Version License Platform

Light-weight, no use image check button.

screenshot1

Features

  • This class is subclass of UIControl.
  • Equip @IBInspectable. You can change color, border in Storyboard.
  • Equip @IBDesignable. You can see check button in storyboard
  • Animate when button pressed.(scale animation)
  • Immediately update when property changed.

Requirements

  • Xcode 8.0
  • Swift 3.0

Installation

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

pod "SUCheckButton"

and run

pod install

Usage

Use in Storyboard

  • Add view in storyboard
  • Change Class to SUCheckButton
  • If you want to change color,border width,etc.. , open Attribute Inspector and change it.

Use in code

import SUCheckButton

// Use convenience initializer
let checkButton = SUCheckButton() // make default frame: {0, 0, 30, 30}

// Use normal initializer
let checkButton = SUCheckButton(frame: CGRectMake(0, 0, 44, 44))

// change color
checkButton.checkedFillColor = UIColor(red: 1.0, green: 0.2, blue: 0.1, alpha: 1.0)

// did press handler
checkButton.didPressHandler = { (checked: Bool) in
    print("status : \(checked)")
}
// also use addTarget:action:forControlEvents:
checkButton.addTarget(self, action: "checkValueChanged:", forControlEvents: .ValueChanged)

If use just mark (not use as a buton), set userInteractionEnabled = false

checkButton.userInteractionEnabled = false

checkButton.checked = true // status : checked. change mark.
checkButton.checked = false // status : unchecked. change mark.

License

MIT license. See the LICENSE file for more info.

About

light-weight check button in Swift.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 2

  •  
  •