A simple range slider made in Swift

Related tags

Slider RangeSlider
Overview

RangeSlider

CI Status License Platform Version Carthage compatible

Summary

A simple range slider made in Swift.

Screenshot

Use

This control is IBDesignable and uses the target-action pattern for change notifications.

In order to be notified when either thumb value changes, register for .ValueChanged:

let rangeSlider = RangeSlider(frame: frame)
view.addSubView(rangeSlider)
rangeSlider.addTarget(self, action: #selector(viewController.rangeSliderValueChanged(_:)),
                         for: .valueChanged)

Configuration

The range slider can be customized and information can be accessed through these properties :

  • minimumValue : The minimum possible value of the range
  • maximumValue : The maximum possible value of the range
  • lowerValue : The value corresponding to the left thumb current position
  • upperValue : The value corresponding to the right thumb current position
  • trackTintColor : The track color
  • trackHighlightTintColor : The color of the section of the track located between the two thumbs
  • thumbTintColor: The thumb color
  • thumbBorderColor: The thumb border color
  • thumbBorderWidth: The width of the thumb border
  • curvaceousness : From 0.0 for square thumbs to 1.0 for circle thumbs

Installation

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

pod "WARangeSlider"

Author

William Archimede

License

RangeSlider is available under the MIT License

If you use it and like it, let me know: @warchimede

Comments
  • doesn't load size and range values unless you touch the knobs

    doesn't load size and range values unless you touch the knobs

    when I run my app, the slider doesn't pick the constraints assigned to it and looks totally out of place, unless I touch one of the knobs and make the gesture of moving them. When I do that touch in the knob, the constraints load and the sizing gets corrected. Am I doing something wrong or is that some problem related to the rangeslider itself??

    opened by gadget00 3
  • How to use in a storyboard

    How to use in a storyboard

    How can I get this to show up in a storyboard? I attempted to mark the RangeSlider class as IBDesignable and assign it to a UIView however at runtime the control doesn't render.

    opened by blkbam 3
  • Swift 3 support

    Swift 3 support

    Hey, great work with the slider! I used it without any problems with Swift 2.2, but then I migrated to Swift 3 and now I have some small problems, it does not compile because of those lines:

    override func layoutSublayersOfLayer(_ layer: CALayer) { super.layoutSublayersOfLayer(layer) updateLayerFrames() }

    the error states this function does not override anything in the superclass...

    opened by nalogowiec 2
  • Added thumbBorderColor and thumbBorderWidth properties

    Added thumbBorderColor and thumbBorderWidth properties

    I modified this library on a project of mine in order to change the thumb border width and color to create the style below. Thought it might be helpful to have included in the library as well.

    RangeSlider

    opened by ajkoshy7 1
  • newValue is not available in didSet method

    newValue is not available in didSet method

    The newValue variable contains the oldValue and not the new one. To access the new value, we just have to call the variable name.

    New in latest version of Swift maybe ?

    opened by maximeloizeau 1
  • Update to Swift 5

    Update to Swift 5

    With the release of Xcode 10.2, you can no longer compile anything from Swift 3. There wasn't much code change needed, just configuration. The configuration updates were the automatic suggested updates from Xcode.

    opened by jbuckner 0
  • not appearing view

    not appearing view

    this is my code. and i only see gray line

    ` let sliderCover = UILabel() let sliderMainView = UIView() var slider = RangeSlider()

    @objc func priceAction(){
        
        
        let priceLabelSTR = UILabel()
        let priceTo = UILabel()
        let priceFrom = UILabel()
        
        let priceToLabel = UILabel()
        let priceFromLabel = UILabel()
        
        
        let PriceSubmitButton = UIButton()
        let PriceCancleButton = UIButton()
        
        
    
       
        PriceLabel.backgroundColor = Colors.lowBlue
        PriceLabel.textColor = .white
        
        view.addSubview(sliderMainView)
        sliderMainView.addSubview(slider)
        sliderMainView.addSubview(priceLabelSTR)
        sliderMainView.addSubview(priceFrom)
        sliderMainView.addSubview(priceTo)
        sliderMainView.addSubview(priceToLabel)
        sliderMainView.addSubview(priceFromLabel)
        sliderMainView.addSubview(PriceSubmitButton)
        sliderMainView.addSubview(PriceCancleButton)
    
        view.addSubview(sliderCover)
    
        
        
        sliderCover.frame = view.frame
        sliderCover.alpha = 0.5
        sliderCover.backgroundColor = UIColor.black
        
        
        sliderMainView.translatesAutoresizingMaskIntoConstraints=false
        sliderMainView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive=true
        sliderMainView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive=true
        sliderMainView.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.3).isActive=true
        sliderMainView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive=true
        sliderMainView.backgroundColor = .white
        view.bringSubviewToFront(sliderMainView)
        sliderCover.bringSubviewToFront(sliderMainView)
        
        
        
        priceLabelSTR.translatesAutoresizingMaskIntoConstraints=false
        priceLabelSTR.trailingAnchor.constraint(equalTo: sliderMainView.trailingAnchor, constant: -16).isActive=true
        priceLabelSTR.topAnchor.constraint(equalTo: sliderMainView.topAnchor, constant: 6).isActive=true
        priceLabelSTR.textColor = Colors.lowBlue
        
        
        slider.translatesAutoresizingMaskIntoConstraints=false
        slider.trailingAnchor.constraint(equalTo: priceLabelSTR.trailingAnchor, constant: 0).isActive=true
        slider.leadingAnchor.constraint(equalTo: sliderMainView.leadingAnchor, constant: 10).isActive=true
        slider.topAnchor.constraint(equalTo: priceLabelSTR.bottomAnchor, constant: -6).isActive=true
        slider.bottomAnchor.constraint(equalTo: sliderMainView.bottomAnchor, constant: 0).isActive=true
    
        //slider.backgroundColor = Colors.yellow
        slider.addTarget(self, action: #selector(sliderAction(_:)), for: .valueChanged)
        slider.upperValue = 1000
        slider.lowerValue = 1000
        slider.maximumValue = maxPrice
        slider.minimumValue = minPrice
        slider.curvaceousness = 0
        slider.frame = sliderMainView.frame`
    

    }

    opened by M0TRIX 0
  • Not working in Xcode 12.3

    Not working in Xcode 12.3

    'RangeSlider' has different definitions in different modules; first difference is definition in module 'WARangeSlider.Swift' found property name 'lowerValue'

    Screenshot 2021-02-22 at 6 56 40 PM

    opened by RahulDhiman93 0
  • Possible bug at end of range + minimum range size

    Possible bug at end of range + minimum range size

    Specifying a range 0-24, the thumb stops at 22, and can't pull it up to 23.

    The other issue is: how to set the minimum range size? It seems to be fixed to 1. I'd need to set it to 0 so that the thumbs could be fully overlapped.

    Thanks a lot, David

    opened by FrizzTheSnail 1
  • Minimum range between upper and lower value.

    Minimum range between upper and lower value.

    Hello, rangeSlider.minimumValue = 0 rangeSlider.maximumValue = 7 rangeSlider.lowerValue = 0 rangeSlider.upperValue = 7

    I'm trying to avoid from user to scroll to same lower & upper values (e.g 7 & 7) is it possible to set minimum value range? (make the user scroll till value:6) Thanks, Ofir.

    opened by OfirMalach 1
  • an FYI: simulator delays in XR

    an FYI: simulator delays in XR

    My first test of the repo was on the XR simulator. Horrible delays in starting the drag motion. Doesn't show up on random testing on older (ie iphone8) simulators.

    opened by wdcurry 0
  • can't able to update the minimum value and maximum value manually

    can't able to update the minimum value and maximum value manually

    when I tried to update the value of minimum value and maximum value of the RangeSlider manually, it shows a error like Assertion failed: RangeSlider: minimumValue should be lower than maximumValue and I have attached my code as well,

    var sliderReference = RangeSlider() ... sliderReference.maximumValue = maximumPrice sliderReference.minimumValue = minimumPrice`

    opened by Vinith253 0
Owner
William Archimede
 software architect
William Archimede
A slider, similar in style to UISlider, but which allows you to pick a minimum and maximum range.

TTRangeSlider A slider, similar in style to UISlider, but which allows you to pick a minimum and maximum range. Installation TTRangeSlider is availabl

Tom Thorpe 952 Dec 2, 2022
RangeSeedSlider provides a customizable range slider like a UISlider.

RangeSeekSlider Overview RangeSeekSlider provides a customizable range slider like a UISlider. This library is based on TomThorpe/TTRangeSlider (Objec

WorldDownTown 644 Dec 12, 2022
PhotoSlider is a simple photo slider and can delete slider with swiping.

PhotoSlider is a simple photo slider and can delete slider with swiping.

Daichi Nakajima 247 Nov 30, 2022
💧 A slider widget with a popup bubble displaying the precise value selected. Swift UI library made by @Ramotion

FLUID SLIDER A slider widget with a popup bubble displaying the precise value selected written on Swift. We specialize in the designing and coding of

Ramotion 1.9k Dec 23, 2022
A reusable Slider View made with SwiftUI

ZSlider A reusable Slider View made with SwiftUI. Installation: Minimum version iOS 13 In Xcode go to File -> Swift Packages -> Add Package Dependency

null 7 Dec 15, 2022
UISlider clone with multiple thumbs and values, range highlight, optional snap intervals, optional value labels, either vertical or horizontal.

MultiSlider UISlider clone with multiple thumbs and values, range highlight, optional snap intervals, optional value labels, either vertical or horizo

Yonat Sharon 326 Dec 29, 2022
TriggerSlider is a simple SwiftUI trigger slider

TriggerSlider is a simple SwiftUI trigger slider which can be used instead of a button, e.g. in a situation where the

Dominik Butz 4 Dec 16, 2022
Simple and light weight slider with chapter management

Simple and light weight slider with chapter management Demo Installation CocoaPods WESlider is available through CocoaPods. To install it, simply add

Lucas Ortis 89 Nov 29, 2022
IntervalSlider is a slider library like ReutersTV app. written in pure swift.

IntervalSlider Description and appetize.io`s DEMO To run the example project, clone the repo, and run pod install from the Example directory first. Re

Nobuyasu 65 May 23, 2021
CircleSlider is a Circular slider library. written in pure Swift.

CircleSlider Description and appetize.io`s DEMO Usage To run the example project, clone the repo, and run pod install from the Example directory first

Nobuyasu 142 May 9, 2022
An iOS Slider written in Swift.

JDSlider Beetripper App's screenshots Example Project To run the example project, clone the repo, and run pod install from the Example directory first

Jelly Development 84 Jul 26, 2022
A beautiful slider control for iOS built purely upon Swift

SnappingSlider A beautiful slider control for iOS. Installation There are two ways to add the control to your project; you can add it as a submodule i

Rehat Kathuria 577 Dec 15, 2022
A feature-rich circular slider control written in Swift.

MTCircularSlider Screenshot Usage To run the example project, clone the repo, and run pod install from the Example directory first. Requirements iOS 1

Eran Boudjnah 132 Jan 1, 2023
VerticalSlider is a vertical slider control for iOS in Swift.

?? VerticalSlider If you like VerticalSlider, give it a ★ at the top right of this page. Overview VerticalSlider is a vertical implementation of the U

Jon Kent 78 Sep 15, 2022
A powerful Circular Slider. It's written in Swift, it's 100% IBDesignable and all parameters are IBInspectable.

CircularSlider A powerful Circular Slider. It's written in Swift, it's 100% IBDesignable and all parameters are IBInspectable. Demo Installation Circu

Matteo Tagliafico 253 Sep 19, 2022
FlowerSlider - Flower Slider Animation Built With Swift

FlowerSlider Shape Slider Screenshot

Joey Graham 4 Sep 27, 2022
VerticalSlider - An animatable and customizable vertical slider written in Swift 4

VerticalSlider An animatable and customizable vertical slider written in Swift 4. Quick Start VerticalSliderPlayground Clone Repo Open VSVerticalSlide

Vincent Smithers 13 Apr 26, 2022
🎚️ STDiscreteSlider – slider which allows user to choose value only from predefined set of data.

STDiscreteSlider – slider which allows user to choose value only from predefined set of data. Slider may receive any types of options, you may pass set of integers or strings, or any other type. Written using SwiftUI.

Tamerlan Satualdypov 15 Apr 3, 2022
Custom & highly configurable seek slider with sliding intervals, disabled state and every possible setting to tackle!

iLabeledSeekSlider Custom & highly configurable seek slider with sliding intervals, disabled state and every possible setting to tackle! Minimum iOS v

Edgar Žigis 9 Aug 16, 2022