VerticalSteppedSlider

A completely configurable slider with options for steps, vertical orientation, and custom colors.

Github stars Tracking Chart

VerticalSteppedSlider

CI Status
Version
License
Platform

Introduction

VerticalSteppedSlider is a completely configurable slider for iOS written in Swift. Configure custom track widths, colors, or images, set the size of the step inrements as well as vertical orientation.

Demo

animated demo

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

VerticalSteppedSlider is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'VerticalSteppedSlider'

Usage

Firstly, import VerticalSteppedSlider.

import VerticalSteppedSlider

Initialization

There are two ways to create a VSSlider:

  • In the storyboard, change the class of a UIView to VSSlider and set the module to VerticalSteppedSlider.
  • In code using an init(frame:CGRect)

Using Increments

The property increment determines where the marks will be drawn on the slider and will round the value to the nearest increment after sliding the slider.

For example, if the minimumValue is -1, maximumValue is 1, and increment is 0.5, the a mark will be drawn at -0.5, 0, and 0.5. Likewise, the slider will only allow the values -1, -0.5, 0, 0.5, and 1 when sliding the slider.

Customizing the Slider’s Appearance

If you want to change the colors of the track and thumb, you can set custom tint colors for both the track and the thumb of a slider, using the minimumTrackTintColor, maximumTrackTintColor, markColor, and thumbTintColor properties. You can also specify the thickness of the track with trackWidth and the weight of the increment marks with markWidth. By default, the minimum track tint color defers to the tint color of the slider control.

You can more finely control the appearance of the slider by specifying the images used to draw the thumb and the track.

The trackExtendsUnderThumb property determines the length of the track. By default, the slider tracks extend before the minimumValue and after the maximumValue in order to make the thumb align with the beginning and end of the slider. This matches the default behavior of Apple's UISlider To turn this off and view a more accurate slider, set trackExtendsUnderThumb to false.

Properties, Topic, Property, Description, Type, Default Value, -------, ---------------, ------------------------------, ------------, ----------------, Accessing the Slider’s Value, value, Current raw value of the slider, not rounded to the nearest the increment. See UISlider.value for more information., Float, 0, roundedValue, Computed property that returns the value rounded to the nearest increment., Float, Accessing the Slider’s Value Limits, minimumValue, See UISlider.minimumValue for more information., Float, 0, maximumValue, See UISliuder.maximumValue for more information., Float, 1, increment, The step increment for the slider. Set to 0 if the slider should be smooth and not round to the nearest increment., Float, 0.5, Modifying the Slider’s Behavior, isContinuous, A Boolean value indicating whether changes in the slider’s value generate continuous update events. See UISlider.isContinuous., Bool, true, Changing the Slider’s Appearance, vertical, If orientation of slider should be vertical or horizontal., Bool, true, ascending, Ascending is defined as: Min on the left and max on the right when horizontal in left-to-right localized layouts.Min on the right and max on the left when horizontal in right-to-left localized layouts.Min on top and max on the bottom when vertical, Bool, false, trackWidth, The thickness of the slider track in points., CGFloat, 2, trackExtendsUnderThumb, Defines if the track should be slightly wider than its min and max values to accomodate for the width of the slider thumb. The value "true" replicates the behavior of UISlider but the increment marks will appear as though there is more space between the first and last marks and the ends of the slider., Bool, true, markWidth, The thickness of the increment marks on the slider in points., CGFloat, 1, markColor, Color of the marks of the slider., UIColor, darkGray, minimumTrackTintColor, The color used to tint the default minimum track images. If minimumTrackImage is non-nil, this is ignored. See UISlider.minimumTrackTintColor for more information., UIColor?, nil, minimumTrackImage, Assigns a minimum track image to the specified control states. Setting this image, calls setMinimumTrackImage() on the internal UISlider for the .normal state. If non-nil, overrides minimumTrackTintColor. See Apple's Customizing the Slider’s Appearance for more information., UIImage?, nil, maximumTrackTintColor, The color used to tint the default maximum track images. If minimumTrackImage is non-nil, this is ignored. See UISlider.minimumTrackTintColor for more information., UIColor?, nil, maximumTrackImage, Assigns a maximum track image to the specified control states. Setting this image, calls setMaximumTrackImage() on the internal UISlider for the .normal state. If non-nil, overrides maximumTrackTintColor. See Apple's Customizing the Slider’s Appearance for more information., UIImage?, nil, thumbTintColor, The color used to tint the default thumb images. If thumbImage is non-nil, this is ignored. See UISlider.thumbTintColor for more information., UIColor?, nil, thumbImage, Assigns a thumb image to the specified control states. If non-nil, overrides thumbTintColor. See Apple's Customizing the Slider’s Appearance for more information., UIImage?, nil, ## License

VerticalSteppedSlider is available under the MIT license. See the LICENSE file for more info.

Main metrics

Overview
Name With Ownermludowise/VerticalSteppedSlider
Primary LanguageSwift
Program languageRuby (Language Count: 5)
Platform
License:MIT License
所有者活动
Created At2017-09-27 19:18:55
Pushed At2020-03-10 19:26:19
Last Commit At2017-10-17 22:50:24
Release Count1
Last Release Name0.1.0 (Posted on )
First Release Name0.1.0 (Posted on )
用户参与
Stargazers Count69
Watchers Count5
Fork Count15
Commits Count21
Has Issues Enabled
Issues Count6
Issue Open Count6
Pull Requests Count0
Pull Requests Open Count2
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private