Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🎨 An intuitive iOS color picker built in Swift.

License

NotificationsYou must be signed in to change notification settings

joncardasis/ChromaColorPicker

Repository files navigation

ChromaColorPicker 2.0

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

ChromaColorPicker GIF

Looking for version 1.x?Version 1.x.x can be found on thelegacy branch. While the pod is still available, it is deprecated and projects should migrate to 2.0.

Examples

letcolorPicker=ChromaColorPicker(frame:CGRect(x:0, y:0, width:300, height:300))addSubview(colorPicker)// Optional: Attach a ChromaBrightnessSlider to a ChromaColorPickerletbrightnessSlider=ChromaBrightnessSlider(frame:CGRect(x:0, y:0, width:280, height:32))addSubview(brightnessSlider)colorPicker.connect(brightnessSlider) // or `brightnessSlider.connect(to: colorPicker)`
  • View theExample app for more.

Usage

Multiple Handles

// Add handle at colorletpeachColor=UIColor(red:1, green:203/255, blue:164/255, alpha:1)colorPicker.addHandle(at: peachColor)// Add handle with referenceletcustomHandle=ChromaColorHandle()customHandle.color=UIColor.purplecolorPicker.addHandle(customHandle)// Add handle and keep referencelethandle= colorPicker.addHandle(at:.blue)

Custom Handle Icon

lethomeHandle=ChomaColorHandle(color:.blue)letimageView=UIImageView(image: #imageLiteral(resourceName:"home-icon").withRenderingMode(.alwaysTemplate))imageView.contentMode=.scaleAspectFitimageView.tintColor=.whitehomeHandle.accessoryView= imageViewhomeHandle.accessoryViewEdgeInsets=UIEdgeInsets(top:2, left:4, bottom:4, right:4)colorPicker.addHandle(homeHandle)

Installation

Carthage

github"joncardasis/ChromaColorPicker"

Cocoapods

pod'ChromaColorPicker'

Manually

Add all files from theSource folder to your project.

Components

ComponentDescription
ChromaColorPickerAn HSB color picker with support for adding multiple color selection handles.
ChromaBrightnessSliderA slider UIControl which can be attached to anyChromaColorPicker via theconnect(to:) method. ChromaBrightnessSlider can also function as a stand-alone UIControl.

Supported UIControlEvents

BothChromaBrightnessSlider andChromaColorPicker conform to UIControl. Each send UIControlEvents which can be observed via viaUIControl'saddTarget method.

ChromaColorPicker

EventDescription
.valueChangedCalled whenever the color has changed.
.touchUpInsideCalled when a handle is released.

ChromaBrightnessSlider

EventDescription
.touchDownCalled when a the slider is grabbed.
.valueChangedCalled whenever the slider is moved and the value has changed.
.touchUpInsideCalled when the slider handle is released.
// ExamplebrightnessSlider.addTarget(self, action: #selector(sliderDidValueChange(_:)), for:.valueChanged)@objcfunc sliderDidValueChange(_ slider:ChromaBrightnessSlider){print("new color:\(slider.currentColor)")}

License

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

About

🎨 An intuitive iOS color picker built in Swift.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors7


[8]ページ先頭

©2009-2025 Movatter.jp