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