Christian1313 / iOS_Swift_ColorPicker

iOS Color Picker written in Swift.
MIT License
40 stars 19 forks source link

ColorPicker as UITextField inputView - Custom Keyboard #3

Open acegreen opened 8 years ago

acegreen commented 8 years ago

Hi,

I was wondering if we can use this library with the new iOS custom keyboards. I already use custom keyboards to display a UIPickerView but was wondering if we can this library as well.

I think all I need to do is assign the view SwiftColorView and make my UITextField class conform to the delegate?

Christian1313 commented 8 years ago

Hallo,

i did not look int custom keyboards. Sadly I can't give you any advice. I hope you try it out and let me know. Perhaps I can integrate a project example for that then.

Christian

acegreen commented 8 years ago

I guess heres our answer :)

simulator screen shot oct 7 2015 9 14 24 am

acegreen commented 8 years ago

Ahh spoke too soon. I noticed I can't click any of the colors.

A few other points regarding the library. It should have a "sort of" random color picker. For example in my case, I want a 5x5 grid but I don't want them to be shades of one another but as many different colors as possible.

So take a look at the example below. The difference in color as you go down is neglect able and not really useful. I want the user to choose a variety of colors. even 20x20, the colors just fade rather than present you with new colors.

simulator screen shot oct 7 2015 9 20 52 am

Christian1313 commented 8 years ago

To change the appearance you can use the brand new SwiftColorPickerDataSource property.

I added the usage of the protocol into the examples. If the dataSource is not set, the usual colors appear.

acegreen commented 8 years ago

Oh ok great.

Can we discuss how to convert the SwiftColorPickerViewController into a UIView?

I started working on it but it doesn't fully work.

This is for the custom keyboard implementation.

Heres the code so far:

https://dl.dropboxusercontent.com/u/8061535/SwiftColorPickerView.swift

Christian1313 commented 8 years ago

Thanks i will take a look, tomorrow.

There is a SwiftColorView already in my code. Is there a sample code for the custom keyboard too?`

acegreen commented 8 years ago

The view will just present it. I need to convert the view to do all the selection and such, just like a UIPickerView

acegreen commented 8 years ago

Updated that code slightly. let me know what you make of it.

acegreen commented 8 years ago

Got it working.

So now I can do

    let pickerViewFrame = CGRectMake(0.0,0.0, UIScreen.mainScreen().bounds.size.width, 216)
    let colorPickerView = SwiftColorPickerView(frame: pickerViewFrame)
    colorPickerView.delegate = self

    colorPickerView.numberColorsInXDirection = 5
    colorPickerView.numberColorsInYDirection = 5
acegreen commented 8 years ago

I'll wrap this into a sample project and fork it over soon.

By the way, where is that SwiftColorPickerDataSource property? I used the .swift file from the master repo.

EDIT: Seems I downloaded an old .swift file. found the datasource, now editing the code

acegreen commented 8 years ago

simulator screen shot oct 7 2015 6 53 40 pm

Christian1313 commented 8 years ago

I look forward for the sample code.

acegreen commented 8 years ago

So how do we do this best. Do I create a new project and repo and reference yours in the read me. or for yours and add my changes?

Christian1313 commented 8 years ago

Best way is that your fork my project and add your changes. You can than add an example for the keyboard use case.

Than i can look into the code and either merge it directly or rewrite my code accordingly.

There is no need for you to link back to me or whatever the license is free to use what ever you want.

acegreen commented 8 years ago

Lets have a chat on Skype when you have some time. I'm noticing a crash when selecting multiple times outside of the patternSize (i.e. on the coloredBorderWidth)

Christian1313 commented 8 years ago

Can you provide a sample code. So i can look into it.

acegreen commented 8 years ago

Created pull request.

Note: This is my first time doing stuff like this, so might not be pulled/requested/added properly.

acegreen commented 8 years ago

@Christian1313 any thoughts?