https://github.com/remirobert/suitchi
Custom Switch for iOS.
https://github.com/remirobert/suitchi
Last synced: 4 months ago
JSON representation
Custom Switch for iOS.
- Host: GitHub
- URL: https://github.com/remirobert/suitchi
- Owner: remirobert
- License: mit
- Created: 2015-03-27T09:18:55.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-02-13T02:53:59.000Z (over 10 years ago)
- Last Synced: 2025-04-15T10:24:53.634Z (about 1 year ago)
- Language: Swift
- Size: 76.2 KB
- Stars: 32
- Watchers: 3
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://developer.apple.com/iphone/index.action)
[](https://developer.apple.com/swift)
[](http://mit-license.org)
[](https://github.com/remirobert/Suitchi/issues?state=open)
**Suitchi** is a custom switch for iOS written in swift. **Suitchi** is highly customizable, you can change almost all parts of this composant. It can display a label in the center of the switch to display some additional information. **Suitchi** handles gesture and simple click.
Customize as you wish.
Installation
============
CocoaPods
```
pod 'Suitchi'
```
Or just copy the **Sources/Suitchi.swift** file in your project.
How it works ?
==============
To make your life easier and make your most beautiful and maintainable code, **Suitchi** uses blocks to retrieve the events.
```Swift
let genderSwitch = Suitchi(frame: CGRectMake(0, 0, 300, 100),
onSwitchedBlock: { () -> () in
println("On !")
}) { () -> () in
println("Off !")
}
```
Get the current state, or change it:
```Swift
if genderSwitch.on {
}
genderSwitch.switchOn()
genderSwitch.switchOff()
```
Some customisation:
```Swift
genderSwitch.offLabel = "Man"
genderSwitch.onLabel = "Woman"
genderSwitch.onColor = UIColor(red:1, green:0.15, blue:0.29, alpha:1)
genderSwitch.offColor = UIColor(red:0.3, green:0.3, blue:0.82, alpha:1)
genderSwitch.centerText = "gender"
```