From 7403472a9954ae9d7cbcdc2e7324d56dcb368184 Mon Sep 17 00:00:00 2001 From: Sachin Patel Date: Thu, 3 Mar 2016 03:36:33 -0800 Subject: [PATCH] Update README and podspec --- ColorSlider.podspec | 4 +- LICENSE.txt | 2 +- README.md | 121 ++++++++++++++++++++++++-------------------- 3 files changed, 70 insertions(+), 57 deletions(-) diff --git a/ColorSlider.podspec b/ColorSlider.podspec index ade5d79..fd6098a 100644 --- a/ColorSlider.podspec +++ b/ColorSlider.podspec @@ -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' diff --git a/LICENSE.txt b/LICENSE.txt index 3c677a6..e650d86 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -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 diff --git a/README.md b/README.md index 2c7d096..68640c8 100644 --- a/README.md +++ b/README.md @@ -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` @@ -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 // ... } ``` @@ -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. \ No newline at end of file