VerticalSlider
An animatable and customizable vertical slider written in Swift 4.
Quick Start
VerticalSliderPlayground
- Clone Repo
- Open VSVerticalSlider.xcworkspace
- In the file navigator open VSVerticalSliderPlayground
- Build with iPhone 8 set as device
- Open assistent editor and set to Live View
For more information on interactive playgrounds read this blog post by Apple Developer
Sample Project
- Clone Repo
- Open VSVerticalSliderSample.xcworkspace
- Build and run.
Installation
CocoaPods
VSVerticalSlider
can be installed with CocoaPods by adding this to your Podfile
:
platform :ios, ’10.0’
target 'VerticalSliderSample' do
use_frameworks!
pod 'VSVerticalSlider', :git => 'https://github.com/vsmithers1087/VerticalSlider.git'
end
Setup
- Create
VSVerticalSlider
with height, color, and optionalx, y
offsets - Set the slider's delegate to self
- Add to your UIView
override func viewDidLoad() {
super.viewDidLoad()
setupSlider()
}
private func setupSlider() {
let slider = VSVerticalSlider(height: 500.0 - 13, primaryColor: UIColor.red, offsetX: 20, offsetY: 40.0)
slider.delegate = self
view.addSubview(slider)
}
Conforming to VerticalSliderDelegate
Receive a callback everytime the slider value changes
extension ViewController: VSVerticalSliderDelegate {
func valueDidChange(value: Int) {
percentageLabel.text = "\(value) %"
}
}
Setting Slider Value
//A value between 0 and 100
let newValue = 51
slider.setValue(newValue)
Todo
- Add Readme
- Setup With Storyboards
- Carthage Support
- Unit Tests
Prerequisites
- Xcode 9.0 +
- Swift 4.0 +
- iOS 10.0 +
Contributing
All feedback and suggestions are welcome. If you see an issue, would like to make a change, or add a feature please make a pull request.
License
VerticalSlider
is released under the MIT License.