Skip to content

Commit 3de0ebb

Browse files
committed
Added convenience method for grayscale
1 parent 9280164 commit 3de0ebb

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed
1.88 KB
Binary file not shown.

GradientSlider/GradientSlider.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ import UIKit
168168
maxColor = UIColor(red: red, green: green, blue: 1.0, alpha: 1.0)
169169
}
170170

171+
func setGradientForGrayscale(){
172+
hasRainbow = false
173+
minColor = UIColor.blackColor()
174+
maxColor = UIColor.whiteColor()
175+
}
176+
171177

172178
//MARK: - Private Properties
173179

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,23 @@ When the `hasRainbow` property is set to true, the track displays a rainbow grad
4747
### Convenience Methods
4848
Since one of the primary uses of the gradient sliders is to create color pickers, a few convenience methods have been provided for updating the colors.
4949

50-
#### HSB
50+
**HSB**
5151
`setGradientForHueWithSaturation(saturation:CGFloat,brightness:CGFloat)` This method sets the track to a rainbow gradient with the given saturation and brightness. This is useful for choosing a hue in the context of the current saturation and brightness settings.
5252

5353
`setGradientForSaturationWithHue(hue:CGFloat,brightness:CGFloat)` This method sets the track to a gradient varying from grey to fully saturated with the hue and brightness provided. This is useful for choosing a saturation value in the context of the current hue and brightness settings.
5454

5555
`setGradientForBrightnessWithHue(hue:CGFloat,saturation:CGFloat)` This method sets the track to a gradient varying from black to full brightness with the hue and saturation provided. This is useful for choosing a brightness value in the context of the current hue and saturation settings.
5656

57-
#### RGB
57+
**RGB**
5858
`setGradientForRedWithGreen(green:CGFloat, blue:CGFloat)` This method sets the track to a gradient with varying red for the given green & blue values.
5959

6060
`setGradientForGreenWithRed(red:CGFloat, blue:CGFloat)` This method sets the track to a gradient with varying green for the given red & blue values.
6161

6262
`setGradientForBlueWithRed(red:CGFloat, green:CGFloat)` This method sets the track to a gradient with varying blue for the given red & green values.
6363

64+
**Grayscale**
65+
`setGradientForGrayscale()` This method sets the track to a gradient from black to white.
66+
6467
## Responding to User Interaction
6568
### Target/Action
6669
As a UIControl subclass, the traditional target/action approach is fully supported. The slider will send TouchDown, ValueChanged, and TouchUpInside actions. If the `continuous` property is set to true (which it is by default), then the slider will send ValueChanged actions as the slider changes, otherwise a ValueChanged action is only sent when the user releases the slider.

0 commit comments

Comments
 (0)