Fader
Fader is a lightweight controller library for Swift heavily inspired by dat.gui.
Code Example
let fader = Fader(frame: .zero)
fader.add(target: particle,
keyPath: \SCNParticleSystem.birthRate,
minValue: 0.0,
maxValue: 1000.0)
By the grammar of the new keypath of Swift 4, we can describe it type-safely shortly.
Usage
- Add Fader view to your screen
- Add x, y, width constraints
- Add codes to specify properties to modify
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Installation
Fader is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Fader'
KeyPath API
Since pure swift class can not get the name from KeyPath, use the label parameter.
Number
fader.add(target: car,
keyPath: \Car.speed,
minValue: 0.0,
maxValue: 120.0)
Boolean
fader.add(target: door,
keyPath: \Door.isClosed)
String
fader.add(target: label,
keyPath: \UILabel.text)
Callback API
Specify initialValue to set the initial value with Callback API.
Number
fader.add(label: "strength", minValue: 0.0, maxValue: 100) { (value: Double) in
self.attackStrength = value
}
Boolean
fader.add(label: "on off") { (isOn: Bool) in
self.switch.isOn = isOn
}
String
fader.add(label: "name") { (str: String?) in
self.nameLabel.text = str
}
Author
ryohey, [email protected]
License
Fader is available under the MIT license. See the LICENSE file for more info.