A feature-rich circular slider control written in Swift.

Overview

MTCircularSlider

CI Status Version License Platform

Screenshot

Screenshot from Simulator

Usage

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

Requirements

  • iOS 10.0+

Installation

CocoaPods (iOS 10.0+)

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

pod "MTCircularSlider"

Manual Installation

The class file required for MTCircularSlider can be found in the following path:

MTCircularSlider/Classes/MTCircularSlider.swift

Usage

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

MTCircularSlider implements IBDesignable and IBInspectable, and so can be configure directly from Interface Builder.

Usage in Code - Simple

To add a default circular slider, add the following code to your controller:

self.slider = MTCircularSlider(frame: self.sliderArea.bounds, options: nil)
self.slider?.addTarget(self, action: Selector("valueChange:"), forControlEvents: .ValueChanged)
self.sliderArea.addSubview(self.slider)

Usage in Code - Advanced

To add a custom circular slider, add the following code to your controller:

let attributes = [
/* Track */
Attributes.minTrackTint(.lightGray),
Attributes.maxTrackTint(.lightGray),
Attributes.trackWidth(12),
Attributes.trackShadowRadius(0),
Attributes.trackShadowDepth(0),
Attributes.trackMinAngle(180),
Attributes.trackMaxAngle(270),

/* Thumb */
Attributes.hasThumb(true),
Attributes.thumbTint(UIColor.darkGrayColor()),
Attributes.thumbRadius(8),
Attributes.thumbShadowRadius(0),
Attributes.thumbShadowDepth(0)
]

self.slider = MTCircularSlider(frame: self.sliderArea.bounds, options: nil)
self.slider.configure(attributes)
self.slider?.addTarget(self, action: Selector("valueChange:"), forControlEvents: .ValueChanged)
self.sliderArea.addSubview(self.slider)

Attributes

minTrackTint(UIColor)

Sets the color of the track up to the thumb.

maxTrackTint(UIColor)

Sets the color of the track from the thumb to the end of the track.

trackWidth(CGFloat)

Sets the width of the track in points.

Default value: 2

trackShadowRadius(CGFloat)

Sets the radius for the inner shadow on the track.

trackShadowDepth(CGFloat)

Sets the distance of the inner shadow on the track from the track edge.

trackMinAngle(Double)

Sets the minimum angle of the track in degrees.

Default value: 0

trackMaxAngle(Double)

Sets the maximum angle of the track in degrees.

Default value: 360

areTrackCapsRound(Bool)

Sets whether the edges of the track around round (true) or flat (false).

Default value: false

maxWinds(Float)

Sets the maximum number of times a user can wind the control. If set to a value other than 1, the difference between the minimum and maximum angles must be exactly 360 degrees.

Default value: 1

hasThumb(Bool)

Toggles the control between progress and slider modes. Setting hasThumb to true set the control to slider mode.

thumbTint(UIColor)

Sets the color of the thumb.

thumbRadius(CGFloat)

Sets the radius of the thumb in points.

thumbShadowRadius(CGFloat)

Sets the radius of the shadow the thumb drops.

thumbShadowDepth(CGFloat)

Sets the distance of the shadow the thumb from the thumb.

Functions

getThumbAngle() -> CGFloat

Returns the current angle of the thumb in radians.

Author

Eran Boudjnah, [email protected]

License

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

Comments
  • Value issue when taping outside of a partial slider

    Value issue when taping outside of a partial slider

    Hi,

    When using a partial Slider as the one in the demo project (the one in the top right corner), if you tap outside of the slider (i.e. tap at the location of the star as shown in the attached screenshot), the value is set to max value.

    slider

    opened by Ezor 9
  • Install Version 1.2.0  not 1.0.0

    Install Version 1.2.0 not 1.0.0

    Captura de Pantalla 2021-07-08 a la(s) 19 10 10 I have already Xcode 12.5.1 , pod version -> 1.10.1'

    the version pod install always 1.0.0 but I need the 1.2.0

    in podFile Specs have

    "# Uncomment the next line to define a global platform for your project" platform :ios, '12.0'

    target 'MyAppTarget' do "# Comment the next line if you're not using Swift and don't want to use dynamic frameworks" use_frameworks!

    pod 'MTCircularSlider '

    end

    the version 1.0.0 do not have the attribute areTrackCapsRound, is there another way to set the corners for the trackPath? not the thumb....

    opened by Yancerva 8
  • slider in a scroll view misbehaves

    slider in a scroll view misbehaves

    I have the circular slider inside a scroll view. tapping to change the value works but dragging it, 95% of the time the scroll view moves, not the slider.

    opened by ghost 8
  • Slider triggers interactive dismissal in iOS 13

    Slider triggers interactive dismissal in iOS 13

    In iOS 13, the new modal presentation style has an interactive dismissal feature that allows you to swipe down to dismiss the view controller. Trying to drag the slider in a presented view controller also triggers this dismissal, making it basically impossible to use.

    opened by naclcaleb 4
  • Is it possible to drag the knob continuously in a circle?

    Is it possible to drag the knob continuously in a circle?

    I set it to go from 0 to 360. I can't drag it past the leftmost point, though I can get around it by clicking to get past that point.

    That would be very nice, though I can understand that it could be difficult to implement. I'm trying to make a control to set and change the direction in a driving app.

    opened by bcichowlas 2
  • UIControlEvents.valueChanged stops audio playing

    UIControlEvents.valueChanged stops audio playing

    Even when is declared in target it stops audio playing though AVPlayer

    self.circleSpinner.addTarget(self, action: #selector(PlayerViewController.circleSpinnerAction), for: UIControlEvents.valueChanged)

    audio just will not play

    opened by pj-wilson 2
  • Changing value of slider

    Changing value of slider

    I'm building a video editing app and I'm using MTCircularSlider to set the current time in the video. The problem is that since it is a video, I set the .value a lot of times per second and MTCircularSlider can't handle. I found a quick fix by deleting the sendActions(for: .valueChanged) and now it works perfectly.

    Before:

        @IBInspectable
        public var value: Float = 0.5 {
            didSet {
                let cappedVal = cappedValue(value: value)
                if value != cappedVal { value = cappedVal }
                setNeedsDisplay()
    
                sendActions(for: .valueChanged)
            }
        }
    

    After

        @IBInspectable
        public var value: Float = 0.5 {
            didSet {
                let cappedVal = cappedValue(value: value)
                if value != cappedVal { value = cappedVal }
                setNeedsDisplay()
            }
        }
    
    opened by lfarah 2
  • Slider not receiving touch events in UIScrollView?

    Slider not receiving touch events in UIScrollView?

    It seems like the slider can't receive touch events from within a scrollview. It was working well before, but the minute I put it in a scrollview it stopped working. As far as I can tell, there's nothing blocking its way or anything, it just won't respond to touches.

    opened by naclcaleb 1
  • "Failed to render and update auto layout status" error

    error: IB Designables: Failed to render and update auto layout status for FirstViewController (9pv-A4-QxB): dlopen(MTCircularSlider.framework, 1): no suitable image found. Did find: MTCircularSlider.framework: required code signature missing for 'MTCircularSlider.framework'

    So far it doesn't seem to affect anything. I am on Xcode 9.4.1

    opened by bcichowlas 1
  • Implementation code help for a newbie

    Implementation code help for a newbie

    Hello and congrats for the idea, is really useful! I'm newbie in Xcode environment, and I need to know what's mean "self.slider" and "self.sliderArea". I add IBAction for UISlider in my ViewController.swift but I know this is not the entire work. Does anybody can help me? Thanks!

    opened by felgarte 1
  • Swift 2.3 compatibility

    Swift 2.3 compatibility

    Few changes to make the project Swift 2.3 (Xcode8) compatible.

    You must have this installer hook in you Podfile to avoid the "USE SWIFT LEGACY" error :

    post_install do |installer|
        installer.pods_project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = "2.3"
            end
        end
    end
    

    Or you can also install the pre version of cocoa pods supporting Swift 2.3.

    opened by Ezor 0
  • Adding Image to Thumb

    Adding Image to Thumb

    I want to add an image to the thumb for the slider and I added that image to the thumb layer but it doesn't get reflected. Please let me know how this can be achieved?

    I added the below code in the prepare method

    thumbLayer.backgroundColor = UIColor.clear.cgColor thumbLayer.contents = UIImage(named:"knobPointer.png")?.cgImage

    opened by networkharry04 0
Owner
Eran Boudjnah
Android Lead (contractor) https://optimisingmylife.com
Eran Boudjnah
A custom reusable slider control with 2 thumbs (range slider).

MARKRangeSlider A custom reusable slider control with 2 thumbs (range slider). Values range is between minimumValue and maximumValue (from 0 to 1 by d

Vadym Markov 181 Nov 21, 2022
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
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
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 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
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
This is an iOS Tweak that modifies the brightness slider in the Control Center.

AdvancedBrightnessSlider Tweak This is an iOS Tweak that modifies the brightness slider in the Control Center. Even with dark mode toggled on, I found

Jonas Schiefner 18 Jan 5, 2023
VolumeControl is a custom volume control for iPhone featuring a well-designed round slider.

#VolumeControl VolumeControl is a custom volume control for iPhone featuring a well-designed round slider. Preview Usage // Include VolumeControl.h in

12Rockets 81 Oct 11, 2022
iOS 11 Control Center Slider

SectionedSlider Control Center Slider Requirements Installation Usage License Requirements iOS 8.0+ Swift 3.0+ Xcode 8.0+ Installation CocoaPods Cocoa

Leonardo Cardoso 361 Dec 3, 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
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
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
A simple range slider made in Swift

RangeSlider Summary A simple range slider made in Swift. Screenshot Use This control is IBDesignable and uses the target-action pattern for change not

William Archimede 305 Nov 29, 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
FlowerSlider - Flower Slider Animation Built With Swift

FlowerSlider Shape Slider Screenshot

Joey Graham 4 Sep 27, 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
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
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
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