A checkbox button UI component for iOS built with Swift.
CheckboxButton
- A subclass of
UIControl
. The container will fit the frame of the control while maintaining its aspect ratio.
This project can be installed in different ways:
- Manual
- Download the project
- Simply copy
CheckboxButton.swift
to your project
- Framework
- Download the project
- Build the CheckboxButton framework
- Embed the framework into your project
- Carthage
- Add
github "chrisamanse/CheckboxButton"
in your Cartfile
- Add
CheckboxButton
can be used in two different ways:
- Interface Builder
- Simply change the class of the
UIView
toCheckboxButton
.
- Simply change the class of the
- Code
- Use the initializer:
init(frame: CGRect)
- Use the initializer:
You can run the example app located in the same project to see how it's used.
CheckboxButton
will be toggled when a .TouchedUpInside
event occurred. You can observe changes in state using the UIControlEvents.ValueChanged
event.
You can check if the checkbox is toggled by reading the on
property. You can also set this property to programmatically set the state of the checkbox.
if checkbox.on {
print("Checkbox is checked")
}
// Toggle
checkbox.on = false // Set to false to uncheck
Copyright (c) 2018 Joe Christopher Paul Amanse
This software is distributed under the MIT License.