Skip to content
This repository has been archived by the owner on Dec 29, 2020. It is now read-only.

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
gizmosachin committed Jan 13, 2015
1 parent 016c953 commit e6e747b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,25 @@ self.colorSlider.frame = CGRectMake(0, 0, 10, 150)
self.view.addSubview(self.colorSlider)
```


`ColorSlider` is a subclass of `UIControl` and supports the following `UIControlEvents`:
- `TouchDown`
- `ValueChanged`
- `TouchUpInside`
- `TouchUpOutside`

You can get the currently selected color with the `color` property.

``` Swift
self.colorSlider.addTarget(self, action: "changedColor:", forControlEvents: UIControlEvents.ValueChanged)

func changedColor(slider: ColorSlider) {
var myColor = slider.color
// ...
}
```


Customize border attributes:

``` Swift
Expand All @@ -42,12 +51,17 @@ self.colorSlider.borderWidth = 2.0
self.colorSlider.borderColor = UIColor.whiteColor()
```


To make it easier to select colors, you can specify padding around the bounds of the `ColorSlider` in which touch input will still edit the color hue.

``` Swift
self.colorSlider.padding = 44.0
```

## Sketchpad

`ColorSlider` comes with a demo project called `Sketchpad` that's a simple drawing app for iPhone. To get it to run in Xcode, you must run `pod install`. Note that this does not require the pre-release version (0.36) of Cocoapods.

## How it Works

`ColorSlider` uses [HSL](http://en.wikipedia.org/wiki/HSL_and_HSV), defaults to saturation: 100% / lightness: 50%, and allows you to modify the hue by sliding up and down. When you slide your finger outside the bounds (+ padding) of the `ColorSlider`, you can modify the lightness of the color, allowing you to select black and white.
Expand Down

0 comments on commit e6e747b

Please sign in to comment.