Git Product home page Git Product logo

swiftcolorpicker's Introduction

SwiftColorPicker

Swift Color Picker Screenshot

##Installation ###CocoaPod Podfile:

use_frameworks!
pod 'SwiftColorPicker'

##Usage ###Simple Example Create a Storyboard with 3 views and set the Classes to ColorWell (UIButton), ColorPicker (UIView) and HuePicker (UIView). Wire the Outlets with the following code:

import SwiftColorPicker

...

@IBOutlet var colorWell:ColorWell?
@IBOutlet var colorPicker:ColorPicker?
@IBOutlet var huePicker:HuePicker?

...
// Setup
pickerController = ColorPickerController(svPickerView: colorPicker!, huePickerView: huePicker!, colorWell: colorWell!)
pickerController?.color = UIColor.redColor()

// get color:
pickerController!.color

// get color updates:
pickerController?.onColorChange = {(color, finished) in
    if finished {
      self.view.backgroundColor = UIColor.whiteColor() // reset background color to white
    } else {
        self.view.backgroundColor = color // set background color to current selected color (finger is still down)
    }
}

##Show case

##License MIT-License

swiftcolorpicker's People

Contributors

chrismanahan avatar dlmv avatar larrylegend avatar matthiasares avatar mrmatthias 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

swiftcolorpicker's Issues

iPhone 7 problem

This works well on previous devices, but on iPhone 7/plus the color picker image remains unchanged. I guess it has something to do with iPhone 7 having a wider color spectrum (extended rgb) than what was before.

iphone7

Crashes in iOS 11 due to nil CGDataProvider

in PickerImage.swift, in createImageFromData, the line imageSource = CGImageSourceCreateWithDataProvider(provider!, nil) generates the Unexpectedly found NULL when unwrapping a value error. When following in debugger, the provider value created in the previous line is NULL.

After further research, the null provider is because iOS 11 rejects a zero length value for mutableData. Adding the following line in the init() fixed it for me.
CFDataSetLength(mutableData, size)

color history

provide a set of color wells with previous colors

Opacity?

How best to add an opacity slider into the control? Thanks!

Image on color picker issue

I've installed manually and I have problems with the Image on Color picker, it creates it but can't be assigned, neither saved in camera roll (made it just for a quick check of any errors), please any suggestions? As I think there is something wrong with DataProvider there:
provider = CGDataProvider(data: mutableData)
but I am new in Programming and swift, so I can't give more information..

How To Use

HI,I am learning swift,but I kind of don't konw how to use this in a project,so can you tell me how to use it? or if there is an example would be great.Thank you so much.

Resize problems

I experienced some problems when using ColorPicker with storyboard and constraints. I managed to solve them, but not sure if it was a best way. So, either I can make a pull request, or you can fix by yourself.

  1. Crash in CFDataSetLength(mutableData, size) in PickerImage.
    I changed this line to
    mutableData = CFDataCreateMutable(kCFAllocatorDefault, size)
    and made all mutableData uses (changeSize and writeColorData) synchronized with a DispatchQueue.

  2. ColorPicker and HuePicker store color data as absolute coordinates, which become wrong after resizing. I made coordinates to be relative, so that in ColorPicker x is exactly saturation and y is exactly brightness, while in HuePicker x is exactly hue.

ColorPicker rendering issue when adapting to macOS

Hello MrMatthias!

Thank you for a great project! I'm working on a macOS app and I'm leveraging your SwiftColorPicker.

My changes are minimal. Mostly replacing instances of UIView with NSView, UIImage with NSImage, etc...

I also added mouse-speciffic event listeners for mouseDown, mouseDragged and mouseUp. Their signature is mostly the same with the exception of mouseUp where I set ended to true. Here's an example:

open override func mouseDown(with event: NSEvent) {
        let p: NSPoint = event.locationInWindow
        let center = self.convert(p, from: nil)
        handleMouseEvent(center, ended: false)
}

Now... I'm encountering a weird bug where everything works correctly, except for the rendering of the ColorPicker upon changing hue. Picking a color from the ColorPicker works as displayed by the color preview square. It's just the rendering that is wrong <see video showing the issue>

Can you please point me to a direction where I can start tackling the bug?

I'm also attaching a zip containing the Xcode project.
macOSColorPicker.zip

Problem with constraints

HI,Matthias
I want to use it both in iPhone and iPad,so I add some constraints to the colorWell,colorPicker and huePicker,but when I tap the huePicker,the colorPicker seems have something wrong,the color is NOT right,so do you have any idea how can I fix it? Thank you so much.

Repository branching, new version release

Hi @MrMatthias,
I am going to use SwiftColorPicker in my project and would like to support that project a bit. However, I would like to know what is the current policy related to repo branching? I see that currently the most active branch is example. I think it is well, as it follows common Pod structure and it is updated to current swift. I have also used it for a while and it looks quite stable. What do you think about merging these changes to master branch and releasing updated version of the library?

I guess that we could fix #12 (and/or #24), merge the example branch and release nice, updated version then.

I am eager to help you that as I find the library really helpful for me :)

Regards,

Mateusz

Example project

Please add Example project to the master branch, so when downloading the zip file, it's possible to quickly take a look at.

I see you have an Example branch.

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.