GithubHelp home page GithubHelp logo

hayashi311 / color-picker-for-ios Goto Github PK

View Code? Open in Web Editor NEW
820.0 32.0 153.0 8.37 MB

Colorful: iOS color picker built with Swift.

License: Other

Ruby 4.05% Swift 95.95%
ios swift ui ui-components uikit color-picker interface-builder autolayout

color-picker-for-ios's Introduction

Colorful

CI Status Version License Platform

How to use it

Podfile

platform :ios, '10.0'
pod "Colorful", "~> 3.0"

Install

$ pod install

Usage

let colorPicker = ColorPicker(frame: ...)
colorPicker.addTarget(self, action: #selector(...), for: .valueChanged)
colorPicker.set(color: .red, colorSpace: .extendedSRGB)
view.addSubview(colorPicker)

You can receive .valueChanged event when user changes color.

Reason why you choose colorful

Beautiful UI with haptic feedback.

Wide color space support

ColorSpace Description
.extendedSRGB The extended sRGB is color space for support wider and deeper representation of color.
.sRGB sRGB (standard Red Green Blue) is often the "default" color space for images that contain no color space information

Dark mode support

Requirements

iOS11 ~

License

Colorful is available under new BSD License. See the LICENSE file for more info.

color-picker-for-ios's People

Contributors

akutsuacts avatar behzadardehei avatar hayashi311 avatar igor-palaguta avatar katsuyoshi avatar s1tnk avatar simonrice avatar snickers0129 avatar xaphod 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  avatar  avatar  avatar  avatar  avatar

Watchers

 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

color-picker-for-ios's Issues

NaN with HRBrightnessSlider

I have had to make this change to avoid my app crashing

Line 191:

if (brightnessCursorX < 0 || isnan(brightnessCursorX)) {
return;
}

(Added NaN check). The problem occurs during setting the color for refreshing the view with new data, via an async queue.

Pod download not up to date

The version I just obtained using cocoa pods has some bugs that are fixed in your current master. For example, programmatically setting the color doesn't have any effect on the views in the pods version, but in your master branch, it has been fixed and does have the expected effect.

get number of tiles in row

i want to adjust view based on number of tiles to be displayed in a view, because the number of tiles is not fixed it changes as per device

so is there any way to get number of tiles.

Cocoapods Installation

When I run it, I get the following error:

[!] An error occurred while processing the post-install hook of the Podfile.

undefined method `project' for #<Pod::Installer:0x007f86f39fef80>

Programmatic Allocation

For those of your having problems with wrong-spaced frames, just add the following code to your controller:

    _colorPickerView.frame = CGRectMake(0.0f, 0.0f, self.view.frame.size.width, self.view.frame.size.height);
    _colorPickerView.colorInfoView.frame = CGRectMake(8.0f, 8.0f, _colorPickerView.colorInfoView.frame.size.width, _colorPickerView.colorInfoView.frame.size.height);
    _colorPickerView.colorMapView.frame = CGRectMake(84.0f, 80.0f, self.view.frame.size.width - 84.0f - 8.0f, _colorPickerView.colorMapView.frame.size.height);
    _colorPickerView.brightnessSlider.frame = CGRectMake(0.0f, 104.0f, self.view.frame.size.width, self.view.frame.size.height - 104.0f);

Swift compatibility

How can I use this in Swift project?

I have added using Cocoapods but I am getting "No such module" error.

Is it possible get color name from selected color code ?

In my scenario I want to get color name after selected the color in color pad, Because in Xcode already one property is available to get the color name using "accessibilityName" word. But this is giving me a color name, After searching on google with that color name it gives different one.

Make HRBrightnessSlider Animated When Moving

It looks a lot better. I've added this to my current project. Played around with all the animation duration, this works the best.

  • (void)updateCursor {
    CGFloat brightnessCursorX = (1.0f - (self.brightness.floatValue - self.brightnessLowerLimit.floatValue) / (1.0f - self.brightnessLowerLimit.floatValue));
    if (brightnessCursorX < 0) {
    return;
    }
    CGPoint point = CGPointMake(brightnessCursorX * _controlFrame.size.width + _controlFrame.origin.x, _brightnessCursor.center.y);
    [UIView animateWithDuration:0.1
    delay:0
    options:UIViewAnimationOptionCurveEaseIn
    animations:^
    {
    _brightnessCursor.center = point;
    _brightnessCursor.color = self.color;
    }
    completion:^(BOOL finished)
    {

        }];
    

    }

colorMapView can not show

follow the step of README
colorMapView can not show
HRBrightnessSlider can show
HRColorInfoView can show

what's wrong with my step?

Support iPad

Do you have any plans to modify this to support the iPad as well?

How to use FullColor ?

Hi,
Like Title , I Use Color Picker Without Interface Builder .
And Set saturationUpperLimit.

colorPickerView.colorMapView.saturationUpperLimit = @1;

And How To Use FullColor Without Interface Builder ?

Thank you to answer.

Always black unless Slider is moved.

The HRColorPickerView always returns black. When I move the slider I can see it is purple, but the brightness is always set to 0 on init. I have set it up just like the example project.

Crash

Getting crash due to hsvColor { preconditionFailure() }()

3.0.1 to CocoaPods repository

Probably 3.0.1 can be pushed to cocoapods repository

If I mention in Podfile, CocoaPods cannot find version

pod 'Colorful', '~> 3.0.1'

Color Picker Only Shows Red colors

Testing this on my iPhone, I am only able to see red colors in the gradient of color options. I don't see green, yellow, blue, or any of the other colors that appear in the image.

Oddly enough, a similar issue occurred for me while using another color picker library.

Do you have any idea why this is happening?

image1

Can't pick up white, and back color from the ColorPickerView

I like the color picker. But unfortunately, it is NOT easy to get a white color on there. Its frustrating. I can't seem to get the white color for the background. Since white & black are the main colors that users will use as the background, so I think changing color picker will be needed here.
Do you have any recommendations ?

Thanks.

Problem displaying Button

Hello and first of all thanks for sharing this awesome ColorPicker.

But there ist one problem I'm currently facing.
When I'm adding another object (like: button, slider, uiView ...) into the scene, it won't display at runtime nor in xCode 6 new Debug Screen.

I don't now the Problem. Maybe You?

bildschirmfoto 2014-09-22 um 09 48 21
bildschirmfoto 2014-09-22 um 09 53 36

can't show

I did install the library from pod and followed the sample code.
View can't be shown, because colorPickerView frame is 0,0,0,0 !
Please fix
Roberto

Also, what about a "close" button to dismiss colorPickerView ?

how to initialize colorPicker.color

I use Color-Picker-for-iOS by storyboard and do implement - (void)viewWillAppear:(BOOL)animated but it doesn't work.Every time I segue to the scene colorpickerview always show the default color(redcolor,the upper left corner of the square).

@implementation LLColorPickerController
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.colorPickerView.color = [UIColor blueColor];//self.color;
}

ARC

does not compile for ARC (auto reference counting) projects
is there a ARC version somewhere ?

UI code don't run on main thread

HRColorMapView.m

  • (void)_init;
    at row: 184

[_initializeQueue addOperationWithBlock:^{
     [self createColorMapLayer];   ---------------> this code may be have problem.
    dispatch_async(dispatch_get_main_queue(), ^{
                                                    (2) ------------> maybe code  here , there will run on main thread

Better directions for customizing UI

Can you include better directions for customizing UI and using it with Autolayout? The various delegate methods and what needs to be implemented is not well-documented and prevents people from using the framework beyond the default.

How to use only Circle Color Picker?

Your Color Picker is very easy to use to compare others. But I want to use only circle colour picker, I have a UIView in that view I want to display this circle Color Picker in centre with out slider (beside the circle color picker). Is it possible? If yes please guide me.

In ColorPicker class I tried to hide addSubview(brightnessSlider) and addSubview(colorMapCursor) in private func setup() . But it is not working.

For example see my image, I want total view like this...
Here I wan to remove slider completely and adjust the color circle in to centre of the view (OR) at least hide slider and adjust the color circle in to centre of the screen.

And how to stop continuous reading values from ColorPicker? Which means I want to call this handleColorChanged function only one time that is last value. Because of I want to call one more function in to this.

Thank you.

Screenshot 2020-06-18 at 11 57 25 AM

Casting Hex Colors

Casting your hex values on info view is loosing some precision, here is the updated method:

    CGFloat rFloat, gFloat, bFloat, aFloat;
    [self getRed:&rFloat green:&gFloat blue:&bFloat alpha:&aFloat];

    int r, g, b;
    r = (int)ceilf(255.0 * rFloat);
    g = (int)ceilf(255.0 * gFloat);
    b = (int)ceilf(255.0 * bFloat);

    return [NSString stringWithFormat:@"#%02x%02x%02x", r, g, b];

Errors in XCode 9 due to createColorMapLayer calling UI APIs on a background thread

Main Thread Checker: UI API called on a background thread: -[UIView frame]
PID: 58164, TID: 12541840, Thread name: (none), Queue name: NSOperationQueue 0x60c00003e000 (QOS: UNSPECIFIED), QoS: 0
Backtrace:
4   ipgmail                             0x000000010eba6d91 -[HRColorMapView createColorMapLayer] + 145
5   ipgmail                             0x000000010eba60ea __23-[HRColorMapView _init]_block_invoke + 42
6   Foundation                          0x00000001119899b7 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
7   Foundation                          0x000000011198981a -[NSBlockOperation main] + 68
8   Foundation                          0x0000000111987cd6 -[__NSOperationInternal _start:] + 778
9   libdispatch.dylib                   0x000000011728643c _dispatch_client_callout + 8
10  libdispatch.dylib                   0x000000011728baf4 _dispatch_block_invoke_direct + 592
11  libdispatch.dylib                   0x000000011728643c _dispatch_client_callout + 8
12  libdispatch.dylib                   0x000000011728baf4 _dispatch_block_invoke_direct + 592
13  libdispatch.dylib                   0x000000011728b884 dispatch_block_perform + 109
14  Foundation                          0x0000000111983ce4 __NSOQSchedule_f + 342
15  libdispatch.dylib                   0x000000011728643c _dispatch_client_callout + 8
16  libdispatch.dylib                   0x000000011728c856 _dispatch_continuation_pop + 967
17  libdispatch.dylib                   0x000000011728ac86 _dispatch_async_redirect_invoke + 780
18  libdispatch.dylib                   0x00000001172921f9 _dispatch_root_queue_drain + 772
19  libdispatch.dylib                   0x0000000117291e97 _dispatch_worker_thread3 + 132
20  libsystem_pthread.dylib             0x00000001177471ca _pthread_wqthread + 1387
21  libsystem_pthread.dylib             0x0000000117746c4d start_wqthread + 13

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.