Giter Site home page Giter Site logo

dmrschmidt / swiftcolorwheel Goto Github PK

View Code? Open in Web Editor NEW
44.0 6.0 8.0 9.24 MB

Delightful color picker wheel for iOS in Swift.

License: Apache License 2.0

Swift 98.00% Objective-C 2.00%
color-picker color colors color-palette color-scheme colorscheme colour colour-picker

swiftcolorwheel's Introduction

SwiftColorWheel

Carthage compatible Swift Package Manager compatible

A beautiful, customizable color wheel for iOS in Swift.

ScreenshotRotating ScreenshotScreenshot

More related iOS Controls

You may also find the following iOS controls written in Swift interesting:

Also check it out on CocoaControls.

If you really like this library (aka Sponsoring)

I'm doing all this for fun and joy and because I strongly believe in the power of open source. On the off-chance though, that using my library has brought joy to you and you just feel like saying "thank you", I would smile like a 4-year old getting a huge ice cream cone, if you'd support my via one of the sponsoring buttons β˜ΊοΈπŸ’•

If you're feeling in the mood of sending someone else a lovely gesture of appreciation, maybe check out my iOS app πŸ’Œ SoundCard to send them a real postcard with a personal audio message.

Buy Me A Coffee

Installation

Swift Package Manager

Just add https://github.com/dmrschmidt/SwiftColorWheel and select "Up to Next Major"

Carthage

Simply add the following to your Cartfile and run carthage update:

github "dmrschmidt/SwiftColorWheel", ~> 1.5

Usage

Either, add a ColorWheel or RotatingColorWheel as a custom UIView subclass to your interface builder. Alternatively, you can of course simply add it programmatically as a subview to any normal UIView.

This will already render your color picker. However it doesn't react on your taps yet. For that, set yourself as it's delegate. See the very simplified code example below:

class MyViewController: UIViewController, ColorWheelDelegate {
    private var colorWheel: ColorWheel!

    override func viewDidLoad() {
        super.viewDidLoad()

        colorWheel = ColorWheel(frame: view.frame)
        colorWheel.delegate = self
        view.addSubview(colorWheel)
    }

    // MARK: - ColorWheelDelegate

    func didSelect(color: UIColor) {
        view.backgroundColor = color
    }
}

Customization

You can modify the look of the color wheel through various exposed properties.

// Extra padding in points to the view border.
colorWheel.padding = 13.0

// Radius in point of the central color circle (for black & white shades).
colorWheel.centerRadius = 5.0

// Smallest circle radius in point.
colorWheel.minCircleRadius = 1.0

// Largest circle radius in point.
colorWheel.maxCircleRadius = 5.0

// Padding between circles in point.
colorWheel.innerPadding = 3

/**
 Degree by which each row of circles is shifted.
 A value of 0 results in a straight layout of the inner circles.
 A value other than 0 results in a slightly shifted, fractal-ish / flower-ish look.
*/
colorWheel.shiftDegree = 0

// Overall density of inner circles.
colorWheel.density = 1.0

// Stroke color highlighting currently selected color. Set nil to disable highlighting.
// Default is UIColor.white.
colorWheel.highlightStrokeColor = nil

In some case (like when a RotatingColorWheel is placed inside a UIScrollView) you may want to tweak the default gesture handling for the rotation. If you do so, you can get access to the original gesture handler and use it in composition.

let originalHandler = rotatingWheel.panRecognizer.delegate
yourRetainedHandler = YourTweakedHandler(complementing: originalHandler)
rotatingWheel.panRecognizer.delegate = yourRetainedHandler
rotatingWheel.rotateRecognizer.delegate = yourRetainedHandler

YourTweakedHandler could then implement gestureRecognizerShouldBegin(_:) in conjunction with the originally provided handler.

See it live in action

SoundCard - postcards with sound lets you send real, physical postcards with audio messages. Right from your iOS device.

SwiftColorWheel is used to color the waveform derived from the audio message on postcards sent by SoundCard - postcards with audio.

Β 

Download SoundCard

Download SoundCard on the App Store.

Β 

Screenshot

swiftcolorwheel's People

Contributors

dmrschmidt avatar kellyroach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

swiftcolorwheel's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.