Light-weight, no use image check button.
- 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.
- Xcode 8.0
- Swift 3.0
SUCheckButton is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "SUCheckButton"and run
pod install- Add view in storyboard
- Change Class to
SUCheckButton - If you want to change color,border width,etc.. , open
Attribute Inspectorand change it.
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.MIT license. See the LICENSE file for more info.
