ColorSlider is a SwiftUI view that displays a color slider

Overview

SwiftUI ColorSlider

im01 im02

ColorSlider is a SwiftUI view that displays a color slider. It is used to dynamically select a color from a range of colors or grayscale.

The main elements are ColorSlider.swift and ColorObject.swift, see the demo in ContenView.swift for how to use it in your code.

The key to using this ColorSlider in your code is to create a ColorObject such as:

@ObservedObject var colorObject = ColorObject()

and pass it to the ColorSlider as shown in ContenView.swift,

ColorSlider(colorObject: colorObject, width: 300, height: 40)

As the slider knob is changed, the current color selected can be obtain from the ColorObject using:

colorObject.color

The following can be set to customise the ColorObject and thus the ColorSlider:

  • nColors, the number of colors to display in the slider, default 100.
  • saturation, the desired saturation value, default 1.
  • brightness, the desired brightness value, default 1.
  • isDraggable, to allow the slider to be dragged around the screen, default true
  • bandSize, to set the thichness of the color bands in the slider, default 1.

ColorSlider will display a slider gradient of colors, from white to black.

For convenience, to display a gray scale slider, initialise the ColorObject as:

@ObservedObject var colorObject = ColorObject(grayScale: true)

For convenience, to display a static slider, initialise the ColorObject as:

@ObservedObject var colorObject = ColorObject(isDraggable: false)    

Example of vertical sliders

For a vertical slider just add:

.rotationEffect(.degrees(90))

The color slider on the left is with the default settings.

The color slider on the right has nColors=10, and a color bandSize=10

im01 im01

You might also like...
Flat UI color palette helpers written in Swift.
Flat UI color palette helpers written in Swift.

FlatUIColors (swift) install Make sure you have the latest version of CocoaPods (gem install cocoapods) that has Swift support. At the time of this wr

A UIColor extension with CSS3 Color names.
A UIColor extension with CSS3 Color names.

CSS3ColorsSwift Overview CSS3ColorsSwift provides a UIColor extension with Web Color names. Demo Run the demo project in the Demo directory without ca

Google Material Color Palette in Swift

Google Material Color in Swift Defined Google Material Color value ready to use in Swift refer to Google Material Design in Style/Color section ###How

A beautiful set of predefined colors and a set of color methods to make your iOS/OSX development life easier.
A beautiful set of predefined colors and a set of color methods to make your iOS/OSX development life easier.

Installation Drag the included Colours.h and Colours.m files into your project. They are located in the top-level directory. You can see a demo of how

Generate color based on the given string.
Generate color based on the given string.

PFColorHash Swift 4.0 SUPPORT! Generate color based on the given string. Thanks to color-hash. Usage Basic let colorHash = PFColorHash() // in HSL, H

A Lightweight But Powerful Color Kit (Swift)
A Lightweight But Powerful Color Kit (Swift)

BCColor A lightweight but powerful color kit (Swift) Features Pick Colors From Image Generate Monochrome Image Support Hex Color Style Lighten / Darke

A simple UIColor category to get color with hex code.
A simple UIColor category to get color with hex code.

TFTColor A simple UIColor library to get UIColor object from RGB hex string/value, CMYK hex string/value or CMYK base component values. You can also r

Aesthetic color-scheme generation written in Swift
Aesthetic color-scheme generation written in Swift

Lorikeet Lightweight framework for generating visually aesthetic color-schemes in Swift Requirements UIKit Features What can Lorikeet do for you Calcu

Overrides macOS external display EDIDs to force RGB color

edidiotic edidiotic creates EDID overrides for external displays on macOS that set the display type to RGB color and removes all extension blocks. Thi

Owner
workingDog
workingDog
System Color Picker - The macOS color picker as an app with more features

System Color Picker The macOS color picker as an app with more features Download Requires macOS 11 or later. Features Quickly copy, paste, and convert

Sindre Sorhus 758 Dec 24, 2022
ColorShift - A ViewModifier that will constantly update the color of a SwiftUI view

A ViewModifier that will constantly update the color of a SwiftUI view. The color will gradient slowly from one color to the next. By default, the initial color is randomly selected.

null 1 Feb 26, 2022
ChromaColorPicker - An intuitive HSB color picker built in Swift

An intuitive HSB color picker built in Swift. Supports multiple selection handles and is customizable to your needs.

Jonathan Cardasis 536 Dec 29, 2022
SheetyColors is an action sheet styled color picker for iOS

?? Based on UIAlertController: The SheetyColors API is based on UIKit's UIAlertController. Simply add buttons to it as you would for any other Action Sheet by defining UIAlertAction instances. Therefore, it nicely integrates with the look & feel of all other native system dialogs. However, you can also chose to use the color picker it self without an action sheet.

Christoph Wendt 102 Nov 10, 2022
HEX color handling as an extension for UIColor. Written in Swift.

SwiftHEXColors HEX color handling as an extension for UIColor. Written in Swift.

Thi Doãn 692 Dec 22, 2022
Convenience methods for creating color using RGBA hex string.

UIColor+Hex, now Swift. Convenience method for creating autoreleased color using RGBA hex string.

R0CKSTAR 1.2k Dec 23, 2022
UIGradient - A simple and powerful library for using gradient layer, image, color

UIGradient is now available on CocoaPods. Simply add the following to your project Podfile, and you'll be good to go.

Đinh Quang Hiếu 247 Dec 1, 2022
A tool to calculate the color ratio of UIImage in iOS.

UIImageColorRatio A tool to calculate the color ratio of UIImage in iOS. How to use UIImageColorRatio Get the color ratio of UIImage. let image = ...

Yanni Wang 王氩 34 Jan 1, 2023
Color framework for Swift & Objective-C (Gradient colors, hexcode support, colors from images & more).

Swift 3 To use the Swift 3 version, add this to your Podfile (until 2.2 or higher is released): pod 'ChameleonFramework/Swift', :git => 'https://githu

Vicc Alexander 12.5k Dec 27, 2022
An attractive color generator for Swift. Ported from randomColor.js.

Random Color Swift Inspired by David Merfield's randomColor.js. It is a ported version to Swift. You can use the library to generate attractive random

Wei Wang 624 Jan 3, 2023