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 way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.

BadgeHub A way to quickly add a notification badge icon to any view. Demo/Example For demo: $ pod try BadgeHub To run the example project, clone the r

Jogendra 772 Dec 28, 2022
:octocat:💧 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
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
UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS

UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS

Mohsan Khan 29 Sep 9, 2022
Whole, half or floating point ratings control written in Swift

FloatRatingView A simple rating view for iOS written in Swift! Supports whole, half or floating point values. I couldn't find anything that easily set

Glen Yi 546 Dec 8, 2022
Fully customizable Facebook reactions like control

Reactions is a fully customizable control to give people more ways to share their reaction in a quick and easy way. Requirements • Usage • Installatio

Yannick Loriot 585 Dec 28, 2022
A page control similar to that used in Instagram

ISPageControl ISPageControl has a page control similar to that used in the Instagram Contents Requirements Installation Usage Communication Credits Li

Interactive 291 Dec 5, 2022
UIStackView replica for iOS 7.x and iOS 8.x

TZStackView A wonderful layout component called the UIStackView was introduced with iOS 9. With this component it is really easy to layout components

Tom van Zummeren 1.2k Oct 10, 2022
Super awesome Swift minion for Core Data (iOS, macOS, tvOS)

⚠️ Since this repository is going to be archived soon, I suggest migrating to NSPersistentContainer instead (available since iOS 10). For other conven

Marko Tadić 306 Sep 23, 2022
A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView and iPhone X safe area support for content reloading. Built for iOS 10 and later.

Arale A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView support for reloading your content. Built f

Putra Z. 43 Feb 4, 2022
BulletinBoard is an iOS library that generates and manages contextual cards displayed at the bottom of the screen

BulletinBoard is an iOS library that generates and manages contextual cards displayed at the bottom of the screen. It is especially well

Alexis (Aubry) Akers 5.3k Jan 2, 2023
💾 A collection of classic-style UI components for iOS

A collection of classic-style UI components for UIKit, influenced by Windows 95 Introduction This is a little exploration into applying '90s-era desig

Blake Tsuzaki 2.2k Dec 22, 2022
A simple, customizable view for efficiently collecting country information in iOS apps.

CountryPickerView CountryPickerView is a simple, customizable view for selecting countries in iOS apps. You can clone/download the repository and run

Kizito Nwose 459 Dec 27, 2022
A library to recreate the iOS Apple Music now playing transition

DeckTransition DeckTransition is an attempt to recreate the card-like transition found in the iOS 10 Apple Music and iMessage apps. Hereʼs a GIF showi

Harshil Shah 2.2k Dec 15, 2022
A message bar for iOS written in Swift.

Dodo, a message bar for iOS / Swift This is a UI widget for showing text messages in iOS apps. It is useful for showing short messages to the user, so

Evgenii Neumerzhitckii 874 Dec 13, 2022
Protocol oriented, type safe, scalable design system foundation swift framework for iOS.

Doric: Design System Foundation Design System foundation written in Swift. Protocol oriented, type safe, scalable framework for iOS. Features Requirem

Jay 93 Dec 6, 2022
A Material Design drop down for iOS

A Material Design drop down for iOS written in Swift. Demo Do pod try DropDown in your console and run the project to try a demo. To install CocoaPods

AssistoLab 2.3k Dec 20, 2022
An easy to use FAQ view for iOS written in Swift

FAQView An easy to use FAQ view for iOS written in Swift. This view is a subclass of UIView. Setup with CocoaPods If you are using CocoaPods add this

Mukesh Thawani 467 Dec 5, 2022
A customizable color picker for iOS in Swift

IGColorPicker is a fantastic color picker ?? written in Swift. Table of Contents Documentation Colors Style Other features Installation Example Gettin

iGenius 272 Dec 17, 2022