joncardasis / chromacolorpicker Goto Github PK
View Code? Open in Web Editor NEW:art: An intuitive iOS color picker built in Swift.
License: MIT License
:art: An intuitive iOS color picker built in Swift.
License: MIT License
I have noticed that currentHandle is not initialized until you move one handle first? This means, that if you first try to change brightness slider, handle (color) is not affected.
I've fixed this with:
// The last active handle.
// SABI TWEAK
// SABI TWEAK
// SABI TWEAK
public var currentHandle: ChromaColorHandle?
//private(set) public var currentHandle: ChromaColorHandle?
And setting currentHandle manually.
Looking at the ChromaAddButton it would be really easy to hide the '+' button (which is functionality I would like/need) but I was wondering how you would like that added as it may affect the public API.
If you would prefer to not have this added, I will likely just add it to my personal fork.
Pods/ChromaColorPicker/ChromaColorPicker/ChromaShadeSlider.swift:50:14: 'let' properties are implicitly 'final'; use 'public' instead of 'open'
Pods/ChromaColorPicker/ChromaColorPicker/ChromaShadeSlider.swift:51:14: 'let' properties are implicitly 'final'; use 'public' instead of 'open'
Pods/ChromaColorPicker/ChromaColorPicker/ChromaShadeSlider.swift:28:14: 'let' properties are implicitly 'final'; use 'public' instead of 'open'
I don't know how to use it
This is a request to add support for removing handles and/or updating their position in code with a color value
My current "workaround" is this:
colorPicker.addButton.plusIconLayer?.removeFromSuperlayer()
colorPicker.addButton.setImage(#imageLiteral(resourceName: "baseline_check_black_24pt"), for: .normal)
colorPicker.addButton.tintColor = .white
colorPicker.addButton.bringSubview(toFront: colorPicker.addButton.imageView!)
But it would be nice if the library had this functionality itself.
Maybe an enum of styles with .plus
and .checkmark
which when changed, swaps the currently shown CASShapeLayer
.
In my app, I draw the picker, but the subviews are not centered on the picker. it is very obvious in iPad.
I'm setting it up like this:
let minwh = 300.0
let pickerSize = CGSize(width: minwh*0.8, height: minwh*0.8)
let pickerOrigin = CGPoint(x: view.bounds.midX - pickerSize.width/2, y: view.bounds.midY - pickerSize.height/2)
/* Create Color Picker */
colorPicker = ChromaColorPicker(frame: CGRect(origin: pickerOrigin, size: pickerSize))
colorPicker.translatesAutoresizingMaskIntoConstraints = false
and I think the issue is that the subviews are based on the beginning of the frame rect while the color picker is centered in the stack view.
However, calling colorPicker.layout()
after the stackview is created does not help.
Allow manual color selection via entering its hex via Hex Field.
Shades of gray not supported?
I created a customHandle, and a homeHandle,
and add snapkit constraints to the homeHandle, so that the home handle will be shown around the colorPicker, not inside the color picker. But the home handle could not respond to the touchUpInside of the ColorPicker. while the customHandle respond to the event. If I remove the snapkit constraints, it respond to the event too. How could I add event processing code to the Home Handle? I hope the color picker could be closed after user click the home handle.
`
// Add handle with reference
let customHandle = ChromaColorHandle()
customHandle.color = UIColor.purple
colorPicker.addHandle(customHandle)
let homeHandle = colorPicker.addHandle(at: .purple)
let customImageView = UIImageView(image: #imageLiteral(resourceName: "home").withRenderingMode(.alwaysTemplate))
customImageView.contentMode = .scaleAspectFit
//customImageView.tintColor = .white
homeHandle.accessoryView = customImageView
homeHandle.accessoryViewEdgeInsets = UIEdgeInsets(top: 35, left: 15, bottom: 30, right: 30)
homeHandle.snp.makeConstraints{(make) -> Void in
make.left.equalTo(colorPicker.snp.left).offset(10)
make.top.equalTo(colorPicker.snp.top).offset(20)
}
`
I have updated Xcode to 10.2 and there is compiler failed : (
Please look at image use link below
https://drive.google.com/open?id=1T8ElVDdJVPvWvPMDyZgsM7h_MAWmknUp
To resolve this, you just need to break your expression into smaller parts.
When archiving, I saw the following error: Target 'Pods-AppName' of project 'Pods' was rejected as an implicit dependency for 'Pods_AppName.framework' because its architectures 'arm64' didn't contain all required architectures 'armv7 arm64'
However, the architecture in the pods was listed as armv7 arm64 and armv7s
. The solution that worked for me was to update cocoapods and reinstall the pod.
gem update cocoapods
pod install
I hope that helps someone else.
I must be missing something but I couldn't find where I can set the alpha.
Please advise.
I have the function below that sets the current value of the ChromaShadeSlider
// This is inside of ChromaShadeSlider.swift
open func setCurrentValue(value: CGFloat){
currentValue = value
handleCenterX = (((currentValue / 2)+0.5) * trackLayer.bounds.width) + (handleWidth/2)
self.layoutHandleFrame()
}
would it be valuable to pull in?
It is currently possible to just directly set the current value with colorPicker.shadeSlider.currentValue = 1.0;
but that doesn't seem to update the handle correctly
The only event that you need to call is .valueChanged, UIControl subclasses call all other events on their own. So when you override endTracking, beginTracking and send event from there, you are sending the duplicate event.
I hope that the color table can support the color extraction of pictures in the album
Hello,
I'm trying to create a pretty simple color selection view and have had a lot of problems with trying to use adjustToColor() with colors only achievable in grayscale. When adjusted to a grayscale color in full color mode or vice versa, the currentColor of the picker seems to become pretty erratic. It's hard to quantify the exact issue, but I think that the adjustToColor() method needs to somehow take grayscale mode into greater consideration.
Thanks,
Kevin
I tried to install library using pod.
Showing errors after pod install , is this swift 3.0 ready ?
Hi,
When call the adjustToColor method on your colorPicker, it does adjust to the color I picked in the circular picker, but not the shade slider, which results in another color being loaded in the picker than I intended. Would it be possible to create a workaround for this?
When ChromaColorPicker is presented over a viewController, The alpha adjustment scroll(supportsShadesOfGray) is not smooth.
`import UIKit
import ChromaColorPicker
class ColorPickerController: UIViewController {
let picker = ChromaColorPicker(frame: CGRect(x: 0, y: 0, width: 350, height: 350))
override func viewDidLoad() {
super.viewDidLoad()
picker.padding = 5
picker.stroke = 3
picker.hexLabel.textColor = UIColor.white
picker.supportsShadesOfGray = true
picker.center = self.view.center
view.addSubview(picker)
view.backgroundColor = .black
}
}`
import UIKit
import ChromaColorPicker
class ViewController: UIViewController,ChromaColorPickerDelegate {
func colorPickerDidChooseColor(_ colorPicker: ChromaColorPicker, color: UIColor) {
print(color)
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
setup()
}
func setup(){
let newController = ColorPickerController()
newController.view.frame = self.view.frame
newController.picker.delegate = self
present(newController,animated: true)
}
}
When presenting a modal controller containing a colorPicker, the following error occurs:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'View has lost track of its superview, most likely through unsupported use of CALayer API on the view's layer. If this isn't a crash yet, it will be in the near future.
Problem view: <ChromaColorPicker_Demo.ChromaHandle: 0x7fd7fcb07e70; frame = (75.0135 0; 24.096 24.096); userInteractionEnabled = NO; layer = <CALayer: 0x600000422680>>
Expected parent: <ChromaColorPicker_Demo.ChromaShadeSlider: 0x7fd7f9d0e0e0; baseClass = UIControl; frame = (78.5385 220.572; 174.123 24.096); gestureRecognizers = <NSArray: 0x60000005b8a0>; layer = <CALayer: 0x6000004231a0>>
Break on UIViewReportBrokenSuperviewChain to debug.'
Suggested fix: in ChromaShadeSlider.swift
Replace:
self.layer.addSublayer(handleView.layer)
by:
self.addSubview(handleView)
When you set a brightness slider and connect it to a picker, the color picker doesn't respond to slider update, unless the user starts dragging the handle.
To avoid this unexpected behaviour I suggest to set colorPicker.currentHandle = colorPicker.handles.last
when a handle is added to the picker.
when this picker is presented in a modal in iOS 14, the "swipe down to dismiss" behavior of the modal makes the picker very difficult to use. seems like the touch is being recognized by the control as well as the navigation controller
The app is getting crashes in iOS 9 when building it from Xcode 12
I am using the ChromaColorPicker library version 1.8.0
Please give me a solution
Thanks
When calling adjustToColor
, the variable currentColor
does not always update itself.
This seems to happen when only the shade of the color was changed.
Looking at the code, it doesn't make sense since I can see it being set from adjustToColor
. However, the only fix I've found is to change currentColor
to a public variable, and to set it to the same value as the one adjustToColor
is called with:
colorPicker.adjustToColor(targetColor)
colorPicker.currentColor = targetColor
Trying to change a previously added handle of place programatically doesn't work, the slider brightness slider moves but the handle in the color picker doesn't. How can I change the handle to a certain color programmatically?
There are several compiling errors when updating to Swift 5
When compiled under Swift 4, the library produces multiple errors related to objc inference. The fix is pretty simple, and easily adds support for the language version.
For those who don't want to wait:
https://github.com/Laptopmini/ChromaColorPicker/releases/tag/1.6.0
Hi, this is a slider with great UX! However to be adopted by apps that is serious about colors it should be support full color scope. As I understand it, Chroma Picker's UI represents HSL model of a color: The radial slider pick Hue value, the horizontal slider picks Luminosity value but there is no slider for chosing Saturation.
That is very unfortunate omission. I suggest that to add option (property) that will enable choosing any RGB color from RGB scope: It will add one more horizontal slider for Saturation in place of Hex value label. If the hex value label needs to be kept (I do not think it's necessary) in full scope mode it should be in smaller font above new Saturation slider.
It would be also great to have Alpha value slider but I admit that I would not know where to put it without breaking the design.
This library has some pretty major issues with AutoLayout that should be looked into.
I was unable to get the ColorPicker to render properly until I constrained its width and height to a constant. I would of loved to use an aspect ratio constraint with leading+trailing margins to the superview, but no matter the combinations I used, the ColorPicker would render its subviews all over the screen.
I am not an AutoLayout newbie, so I know my constraints were valid. I can provide more detail if needed.
Receiving the error: https://github.com/joncardasis/ChromaColorPicker.git has no Package.swift manifest for version 2.0.2 when attempting SPM inclusion via:
.Package(url: "https://github.com/joncardasis/ChromaColorPicker.git", .upToNextMajor(from: "2.0.2"))
Seems all that is needed is a minor version release to tag the Package.swift file.
Is it possible for the user to enter a color value to select a color?
It is impossible to change size of Color Picker Handle, that small circle.
The method adjustToColor(color: UIColor)
mentioned in the documentation is no where to be found in the code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.