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

Commit

Permalink
Update README and podspec
Browse files Browse the repository at this point in the history
  • Loading branch information
gizmosachin committed Mar 3, 2016
1 parent ee8cf57 commit 7403472
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 57 deletions.
4 changes: 2 additions & 2 deletions ColorSlider.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'ColorSlider'
s.version = '2.2'
s.summary = 'iOS Snapchat-style color picker'
s.version = '2.3'
s.summary = 'Snapchat-style color picker with live preview'
s.homepage = 'http://github.com/gizmosachin/ColorSlider'
s.license = 'MIT'
s.social_media_url = 'http://twitter.com/gizmosachin'
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-Present Sachin Patel (http://gizmosachin.com/)
Copyright (c) 2016-Present Sachin Patel (http://gizmosachin.com/)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
121 changes: 67 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,25 @@
## ColorSlider
# ColorSlider

`ColorSlider` is a Snapchat-style color picker written in [Swift](https://developer.apple.com/swift/). It supports changing color hue when dragging inside the bounds of the control and modifying color lightness when dragging outside its bounds, allowing you to select black and white.
ColorSlider is a [Swift](https://developer.apple.com/swift/) color picker with a live preview.

Inspired by Snapchat, ColorSlider lets you drag vertically to pick a range of colors and drag to the edges of the superview to select black and white. You can configure and customize `ColorSlider` via a simple API, and receive callbacks via `UIControlEvents`.

![ColorSlider](https://raw.githubusercontent.com/gizmosachin/ColorSlider/master/ColorSlider.gif)

![Pod Version](https://img.shields.io/cocoapods/v/ColorSlider.svg) [![Build Status](https://travis-ci.org/gizmosachin/ColorSlider.svg?branch=master)](https://travis-ci.org/gizmosachin/ColorSlider)

## Installation

### CocoaPods

`ColorSlider` is available for installation using [CocoaPods](http://cocoapods.org/). To integrate, add the following to your Podfile`:

``` ruby
platform :ios, '9.0'
use_frameworks!

pod 'ColorSlider', '~> 2.2'
```

### Carthage

`ColorSlider` is also available for installation using [Carthage](https://github.com/Carthage/Carthage). To integrate, add the following to your `Cartfile`:

``` odgl
github "gizmosachin/ColorSlider" >= 2.2
```

### Swift Package Manager

`ColorSlider` is also available for installation using the [Swift Package Manager](https://swift.org/package-manager/). Add the following to your `Package.swift`:

``` swift
import PackageDescription

let package = Package(
name: "MyProject",
dependencies: [
.Package(url: "https://github.com/gizmosachin/ColorSlider.git", majorVersion: 0),
]
)
```

### Manual

You can also simply copy the `ColorSlider.swift` file into your Xcode project.

## Usage

The sample project `Sketchpad` provides an example of how to integrate `ColorSlider` with Interface Builder, but you can also follow the steps below. `ColorSlider` has several `IBInspectable` appearance properties that you can edit right from Interface Builder, if you choose to go that route.

Create and add an instance of `ColorSlider` to your view hierarchy.
Create and add an instance of ColorSlider to your view hierarchy.

``` Swift
let colorSlider = ColorSlider()
colorSlider.frame = CGRectMake(0, 0, 10, 150)
colorSlider.frame = CGRectMake(0, 0, 12, 150)
view.addSubview(colorSlider)
```

`ColorSlider` is a subclass of `UIControl` and supports the following `UIControlEvents`:
ColorSlider is a subclass of `UIControl` and supports the following `UIControlEvents`:

- `.TouchDown`
- `.ValueChanged`
Expand All @@ -69,10 +30,10 @@ view.addSubview(colorSlider)
You can get the currently selected color with the `color` property.

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

func changedColor(slider: ColorSlider) {
var myColor = slider.color
var color = slider.color
// ...
}
```
Expand All @@ -83,23 +44,75 @@ Enable live color preview:
colorSlider.previewEnabled = true
```

Use a horizontal slider:

```swift
colorSlider.orientation = .Horizontal
```

Customize appearance attributes:

``` Swift
colorSlider.cornerRadius = 2.0
colorSlider.borderWidth = 2.0
colorSlider.borderColor = UIColor.whiteColor()
colorSlider.edgeInsets = UIEdgeInsetsMake(0.0, 20.0, 0.0, 20.0)
```

## Sketchpad
## Installation

### CocoaPods

ColorSlider is available for installation using [CocoaPods](http://cocoapods.org/). To integrate, add the following to your Podfile`:

``` ruby
platform :ios, '9.0'
use_frameworks!

`ColorSlider` comes with an example project called `Sketchpad`, a simple drawing app. To try it, install [CocoaPods](http://cocoapods.org/) and run `pod install` under the `Example` directory. Then, open `Example > Sketchpad.xcworkspace`.
pod 'ColorSlider', '~> 2.3'
```

### Carthage

ColorSlider is also available for installation using [Carthage](https://github.com/Carthage/Carthage). To integrate, add the following to your `Cartfile`:

``` odgl
github "gizmosachin/ColorSlider" >= 2.3
```

### Swift Package Manager

ColorSlider is also available for installation using the [Swift Package Manager](https://swift.org/package-manager/). Add the following to your `Package.swift`:

``` swift
import PackageDescription

let package = Package(
name: "MyProject",
dependencies: [
.Package(url: "https://github.com/gizmosachin/ColorSlider.git", majorVersion: 0),
]
)
```

### Manual

You can also simply copy `ColorSlider.swift` into your Xcode project.

## Example Project

ColorSlider comes with an example project called Sketchpad, a simple drawing app. To try it, install [CocoaPods](http://cocoapods.org/) and run `pod install` under the `Example` directory. Then, open `Sketchpad.xcworkspace`.

## How it Works

`ColorSlider` uses [HSL](http://en.wikipedia.org/wiki/HSL_and_HSV) and defaults to saturation 100% and lightness: 50%. Dragging up and down modifies the color hue. When you slide your finger outside the bounds of the `ColorSlider`, you can modify the lightness of the color, allowing you to select black and white.
ColorSlider uses [HSB](https://en.wikipedia.org/wiki/HSB) and defaults to a saturation and brightness: 100%.

When the `orientation` is set to `.Vertical`, dragging vertically adjusts the hue, and dragging outside adjusts the saturation and brightness as follows:

- Inside the frame, dragging vertically adjusts the hue
- Outside the frame, dragging horizontally adjusts the saturation
- Outside the frame, dragging vertically adjusts the brightness

Adjusting the brightness lets you select black and white by first dragging on the slider, then moving your finger outside the frame to the top left (to select white) or bottom left (to select black) of the superview.

## License

ColorSlider is available under the MIT license, see the [LICENSE](https://github.com/gizmosachin/ColorSlider/blob/master/LICENSE) file for more information.
ColorSlider is available under the MIT license, see the [LICENSE](https://github.com/gizmosachin/ColorSlider/blob/master/LICENSE) file for more information.

0 comments on commit 7403472

Please sign in to comment.