gizmosachin / colorslider Goto Github PK
View Code? Open in Web Editor NEW๐จ Snapchat-style color picker in Swift
License: MIT License
๐จ Snapchat-style color picker in Swift
License: MIT License
is there any love for iOS 8?
I get the error
Specs satisfying the
ColorSlider (= 2.5.1)
dependency were found, but they required a higher minimum deployment target.
from Cocoapods
Programmatic init per docs does not work:
colorSlider = ColorSlider()
Needs to be called with a frame, even if just zero:
colorSlider = ColorSlider(frame: CGRectZero)
Hello,
I wanted to duplicate the color slider with two different sets of color palette by entering the new color values under colorSliderGradient function and controlling it by using a switch to toggle. Colorslider background changes well as expected however previous slider PreviewView still appears at behind the slider in addition to new defaultPreviewView in front. Whenever toggle the slider color palette small PreviewView icons increases behind the slider. I call addColorSlider function in the view controller every time the toggle button pressed. Any idea how to remove the old PreviewView icons from background. Many thanks indeed
Hey! Thank you for this awesome library.
One small question. If I need to change the starter color (from white to black, to black to right, in my case), how would you recommend doing that?
If i wanted to add a bar, so the user could visually see where they were pressing a bit more clearly, where in the code would I add this? i've tried adding it into the commoninit as well as the drawRect, however the UIView i attempt to place on top is never visible. Only if I add it in the VC where the colorSlider is instantiated, can I do this, but this feels like bad approach. I don't want it like the example, where a color preview circle appears outside of the bar.
If you manually set randomly calculated color, ColorSlider (though setting correct color) slider's position is not set appropriately (always at the 0 position on the left).
I understand why (because ColorsSlider does not "contain" every color possible), but it would be cool if control could approx. calculate the correct position.
It would be great to be able to force a color value at any time on the Color slider. We could imagine that we'd want to save the latest selected color in the user settings and set that color back when he comes back.
What do you think?
hey
I want to move the slider value to a new position programmatically , I found a method name is centerPreview(at:) , but it defines as an internal func , could you tell me how can I do ?
Thanks for all the work @gizmosachin! Great project.
I've been trying to integrate the component like you did in Sketchpad, but for some reason IB is refusing to recognize ColorSlider as a valid subclass for a UIView...
Have you had any experience with this/ know how to debug this?
It's reversed, so when i'm sliding to the left, it's showing colors on the right hand side of the slider. how can i fix this?
First off this is an excellent module, great work.
I have been playing around with the Sketchpad example and can't seem to get the horizontal orientation to function properly. I have tried editing the default orientation, as well as the drawLayer inside commonInit(), but the color slider always appears vertical.
I have noticed that when you are sliding away from the slider the brightness seems to glitch and is most of the time not the correct darker color where I started sliding from.
Thanks for the great library. I would like to have some UISlider type features on this but I am not sure how to approach this.
Currently "valueChanged" event is triggered many times while user is moving the slider thumb. I would like to get an event triggered only when user has completed sliding. UISlider has a property named "continuous" which helps for this kind of situation. However I am not sure how to approach this with ColorSlider.
I would also like to separate the slider thumb from preview view. Right now the slider thumb is acting as preview too. I would like to set a thumb image similar to UISlider which doesn't change its color based on slider position. Instead I would like to connect a separate UIView as Preview View for slider and that UIView would be a fixed static view without any animation along with slider movement. I guess I can implement the thumb image part by implementing "ColorSliderPreviewing" protocol, but just wanted to confirm that. I will also listen to "valueChanged" event for updating preview view background color. Hope that is the right approach.
Trying to add additional white and black colors to the picker and failing. Any ideas on how to implement?
Thanks
I've noticed that on iOS12 little preview drag-UIView is missing?
On iPad after rotations this happens (look at the image).
Is there an option to force re-layout ColorSlider?
I tried layoutIfNeeded, etc. But no success Preview UIView is not correctly repositioned upon device rotations.
The easiest way to reproduce it is like this:
swift 4.2 support would be nice, will PR if i have a chance
Hi there! Wanted to let you know that when I try to initialize a color slider object, the only init method made available is
ColorSlider(orientation: <#T##Orientation#>, previewView: <#T##PreviewView?#>)
Also, the DefaultPreviewView() is not accessible as well.
I am using pod version 4.0.
Thanks!
As Titled. Adding a check inside hitTest() for whether the slider is hidden fixes the issue
/// MARK: - Increase Tappable Area
extension ColorSlider {
/// Increase the tappable area of `ColorSlider` to a minimum of 44 points on either edge.
override public func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
if isHidden || alpha <= 0.01 { return super.hitTest(point, with: event) }
// Determine the delta between the width / height and 44, the iOS HIG minimum tap target size.
// If a side is already longer than 44, add 10 points of padding to either side of the slider along that axis.
let minimumSideLength: CGFloat = 44
let padding: CGFloat = -20
let dx: CGFloat = min(bounds.width - minimumSideLength, padding)
let dy: CGFloat = min(bounds.height - minimumSideLength, padding)
// If an increased tappable area is needed, respond appropriately
let increasedTapAreaNeeded = (dx < 0 || dy < 0)
let expandedBounds = bounds.insetBy(dx: dx / 2, dy: dy / 2)
if increasedTapAreaNeeded && expandedBounds.contains(point) {
for subview in subviews.reversed() {
let convertedPoint = subview.convert(point, from: self)
if let hitTestView = subview.hitTest(convertedPoint, with: event) {
return hitTestView
}
}
return self
} else {
return super.hitTest(point, with: event)
}
}
}
I'm on the horizontal mode.
Is there any easy way to prevent TouchUpInside be called twice?
colorSlider.addTarget(self, action: #selector(changedColor(_:)), for: .touchUpInside)
I want to show the colorslider without preview mode ? What should i do?
Hi and thanks for the great work!
When I'm trying to build the project with Carthage, I have the following error:
/Carthage/Checkouts/ColorSlider/Sources/GradientView.swift:241:23: error: use of undeclared type 'Gradient'
fileprivate extension Gradient {
^~~~~~~~
I'm using Xcode 9.2 / Swift 4
Cheers!
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.