Contents

sardon/graduatedslider

A slider control with graduations (e.g. like sliders on DJ decks), vertical or horizontal, with optional haptic feedback. Supports iOS (UIKit + SwiftUI) and macOS (AppKit + SwiftUI).

Features

  • iOS (UIKit) and macOS (AppKit) support
  • SwiftUI wrapper (GraduatedSliderView)
  • IBInspectable / IBDesignable
  • Customizable graduations and cursor colors
  • Customizable range
  • Optional haptic feedback
  • Horizontal or vertical orientation

Usage

UIKit / AppKit

let slider = GraduatedSlider()
slider.minimumValue = 0
slider.maximumValue = 100
slider.value = 50

// UIKit
slider.addTarget(self, action: #selector(onValueChanged(_:)), for: .valueChanged)

// AppKit
slider.addTarget(self, action: #selector(onValueChanged(_:)))

SwiftUI

import GraduatedSlider

struct ContentView: View {
    @State private var value: CGFloat = 0.5

    var body: some View {
        GraduatedSliderView(value: $value)
            .frame(width: 44, height: 220)
    }
}

Horizontal orientation:

GraduatedSliderView(value: $value, isHorizontal: true)
    .frame(width: 220, height: 44)

Requirements

  • iOS 10.0+ / macOS 10.13+
  • Xcode 12+
  • Swift 5

Installation

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/sardon/GraduatedSlider", from: "1.2.0")
]

Or add it via Xcode: File → Add Package Dependencies… and enter the repository URL.

Meta

I made this for Camera1

https://github.com/sardon/GraduatedSlider

[swift-image]:https://img.shields.io/badge/swift-5.0-orange.svg [swift-url]: https://swift.org/ [license-image]: https://img.shields.io/badge/License-MIT-blue.svg [license-url]: LICENSE.txt

Package Metadata

Repository: sardon/graduatedslider

Default branch: main

README: README.md