iOS 11 Control Center Slider

Overview

SectionedSlider

iOS watchOS

Platform CocoaPods Carthage Compatible

Control Center Slider

Requirements

  • iOS 8.0+
  • Swift 3.0+
  • Xcode 8.0+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.1.0+ is required to build SectionedSlider 0.0.5+.

To integrate SectionedSlider into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'SectionedSlider', '~> 0.0.5'

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate SectionedSlider into your Xcode project using Carthage, specify it in your Cartfile:

github "LeonardoCardoso/SectionedSlider" ~> 0.0.5

Manually

If you prefer not to use either of the aforementioned dependency managers, you can integrate SectionedSlider into your project manually.

Usage

You can use a SectionedSlider on Storyboards or, if you want to do it programatically, you can create it just like you create a UIView:

SectionedSlider(
    frame: CGRect(x: 0, y: 0, width: 78, height: 200), // Choose a 15.6 / 40 ration for width/height
    selectedSection: 3, // Initial selected section
    sections: 10 // Number of sections. Choose between 2 and 20
)

Palette

You also can customize the colors of the button on its constructor.

SectionedSlider(
    frame: wrapView.frame,
    selectedSection: 3,
    sections: 10,
    palette: Palette(
        viewBackgroundColor: UIColor?,
        sliderBackgroundColor: UIColor?,
        sliderColor: UIColor?
    )
)

palette

Delegate

You can watch changes of state by implementing the protocol:

public protocol SectionedSliderDelegate {
    
	func sectionChanged(slider: SectionedSlider, selected: Int)
    
}

Storyboard

Last but not least, you can customize SectionedSlider properties right from Interface Builder or Storyboards.

storyboard

License

SectionedSlider is released under the MIT license. See LICENSE for details.

Comments
  • Can't install CocoaPod

    Can't install CocoaPod

    Im not sure whats happing but, I use Cocoa Pods quite frequently so I know it's not a noob issue, but I can't get the CocoaPod to install, but as soon as I remove SectionedSlider, it works fine. Any ideas? Running Xcode 8.3.3 and updated my CocoaPod installation too.

    invalid 
    opened by sdevo619 7
  • Unable to select more than 10 sections

    Unable to select more than 10 sections

    When I try to have more than 10 sections (for example 20) and try to select 16 (selectedSection: 16, sections: 20) on slider initialization, I was not able to see the 16 selected sections. After looking at the code, I realized that because on initialization, the selectedSection variable is updated before the sections variable, my change on sections value does not take place and thus selectedSection is capped to 10.

    Solution: if you swap the place of initializing sections and selectedSection, everything should work. For reference, swap line 490 with line 491. The problem comes from didSet on line 440.

    I don't mind forking the repo and using my own version of the slider, but I really want to benefit from future updates since this is one great project which is made amazingly well. Congratulations :) I would be thankful if you made this simple fix.

    opened by simonnoff 4
  • selectedSection is inaccessible due to internal protection level

    selectedSection is inaccessible due to internal protection level

    I have the slider in a tableviewcell and need to set the selectedSection each time cellForRowAtIndexPath is called. The property however is not accessible.

    opened by JonnyLinja 2
  • Cannot find protocol declaration for 'SectionedSliderDelegate'

    Cannot find protocol declaration for 'SectionedSliderDelegate'

    I Installed using pods on Objective-C Project. The SectionedSliderDelegate not founded in <SectionedSlider/SectionedSlider-Swift.h>

    After that I removed from pods list and added manually to the project and the result was same. in myproject-Swift.h:

    SWIFT_CLASS("_TtC11gogoMessage15SectionedSlider")
    @interface SectionedSlider : UIView
    @property (nonatomic, strong) UIColor * _Nullable viewBackgroundColor;
    @property (nonatomic, strong) UIColor * _Nullable sliderBackgroundColor;
    @property (nonatomic, strong) UIColor * _Nullable sliderColor;
    @property (nonatomic) NSInteger sections;
    @property (nonatomic) NSInteger selectedSection;
    SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly) Class _Nonnull layerClass;)
    + (Class _Nonnull)layerClass SWIFT_WARN_UNUSED_RESULT;
    - (nonnull instancetype)initWithFrame:(CGRect)frame OBJC_DESIGNATED_INITIALIZER;
    - (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)aDecoder OBJC_DESIGNATED_INITIALIZER;
    - (void)awakeFromNib;
    - (void)drawLayer:(CALayer * _Nonnull)layer inContext:(CGContextRef _Nonnull)ctx;
    - (void)draw;
    - (void)needsDisplay;
    - (void)touchesBegan:(NSSet<UITouch *> * _Nonnull)touches withEvent:(UIEvent * _Nullable)event;
    - (void)touchesMoved:(NSSet<UITouch *> * _Nonnull)touches withEvent:(UIEvent * _Nullable)event;
    @end
    
    
    SWIFT_CLASS("_TtC11gogoMessage20SectionedSliderLayer")
    @interface SectionedSliderLayer : CALayer
    @property (nonatomic) CGFloat factor;
    - (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
    - (nonnull instancetype)initWithLayer:(id _Nonnull)layer OBJC_DESIGNATED_INITIALIZER;
    - (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)aDecoder OBJC_DESIGNATED_INITIALIZER;
    @end
    
    
    SWIFT_CLASS("_TtC11gogoMessage8StyleKit")
    @interface StyleKit : NSObject
    - (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
    @end
    
    typedef SWIFT_ENUM_NAMED(NSInteger, SectionedSliderResizingBehavior, "ResizingBehavior") {
      SectionedSliderResizingBehaviorAspectFit = 0,
    /// The content is proportionally resized to fit into the target rectangle.
      SectionedSliderResizingBehaviorAspectFill = 1,
    /// The content is proportionally resized to completely fill the target rectangle.
      SectionedSliderResizingBehaviorStretch = 2,
    /// The content is stretched to match the entire target rectangle.
      SectionedSliderResizingBehaviorCenter = 3,
    };
    

    As you see there is no property named delegate. I don't know why it wasn't Imported Any Idea?

    opened by behrad-kzm 2
  • change section separators color to be clear and invisible

    change section separators color to be clear and invisible

    Is possible to make secttion separator invisible. In iOS control center there is similar slider and this one is nice example of apples one. However it would be nice that section separators can be clear color and invisible. Any code sample for this trick? Thanks

    opened by qsdnino 1
  • Enable use in UITableView

    Enable use in UITableView

    Variables sections and selectedSection were made open so it's possible to actually programmatically change the value rather than just listen to changes via the delegate function. Without this, the only way to really change it is to recreate the entire SectionedSlider.

    TouchedMoved were swapped out for pan gestures so the gesture recognizers could operate with that of a scrollView. Otherwise, the pan gesture of the scrollView would activate when you're trying to use the Sectioned Slider. Note that this was only tested via Storyboards (aka using awakeFromNib), I haven't tested it via programmatic creation init(frame: CGRect, selectedSection: Int, sections: Int, palette: Palette = Palette())

    opened by JonnyLinja 1
  • Fix first incorrect delegate call

    Fix first incorrect delegate call

    Hey! Thanks for this great control.

    Just came across a small bug, looks like observers don't run in the initializer for swift which causes a first delegate call with 0.0 (Factor's default value) instead of the value you can put in the initializer for selected section.

    Let me know what you think 👍

    opened by jugutier 1
  • Section Changed Delegate should not be called when setting the selectedSection.

    Section Changed Delegate should not be called when setting the selectedSection.

    Section Changed Delegate should not be called when setting the selectedSection. This is the default pattern in all the iOS controls. Check UISegmentControl.

    invalid 
    opened by samonesim 0
  • Fix delegate reference cycle (memory leak) and upgrade to swift 5.0

    Fix delegate reference cycle (memory leak) and upgrade to swift 5.0

    Hey,

    I've separated the content to 4 commits:

    1. Upgrade Swift 3.0 -> 4.2
    2. Upgrade Swift 4.2 -> 5.0
    3. Change the Example project to have a navigation controller leading to the view controller, so it's easy to show the leak
    4. Fix the leak

    To reproduce:

    • Go to the 3rd commit and run the example
    • Enter the slider VC, then back out, repeat a couple of times
    • Use Xcode's "Debug Memory Graph"

    You'll see that there are multiple ViewControllers up, rather than one: image

    The 4th commit fixes this. More info on delegates and retains cycles here.

    Hope you can approve this PR and update the Pod!

    opened by yonilevy 0
  • Landscape Option

    Landscape Option

    Hey, I love that someone came out with this.

    I was wondering if you plan on, or could add an option to use it in Landscape rather than in Portrait only.

    enhancement help wanted good first issue 
    opened by dhruveonmars 10
Releases(0.0.5)
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
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
A custom reusable circular / progress slider control for iOS application.

HGCircularSlider Example To run the example project, clone the repo, and run pod install from the Example directory first. You also may like HGPlaceho

Hamza Ghazouani 2.4k Jan 4, 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
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
Use UIResponder to imitate an iOS slider.

WWSlider Use UIResponder to imitate an iOS slider. 使用UIResponder仿造一個iOS的滑桿. Installation with Swift Package Manager dependencies: [ .package(url:

William-Weng 2 May 5, 2022
Customizable animated slider for iOS

MMSegmentSlider MMSegmentSlider is an easy-to-use IBDesignable animated slider for iOS 7+ written in Objective-C. Installation From CocoaPods CocoaPod

Max Medvedev 48 Jul 26, 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
Customizable animated slider for iOS

MMSegmentSlider MMSegmentSlider is an easy-to-use IBDesignable animated slider for iOS 7+ written in Objective-C. Installation From CocoaPods CocoaPod

Max Medvedev 48 Jul 26, 2022
An iOS-16-styled slider.

Slyderin An iOS-16-styled slider. Available on iOS 13 and later. Slyderin.Demo.mov How to Use Include it with Swift Package Manager. Add it to your vi

iMoeNya 3 Jan 1, 2023
🎚️ 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
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
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