Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
jernejstrasner committed Aug 1, 2015
1 parent 1e2ab69 commit 92bd4a5
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
## Smooth gradients on iOS using CGShading
# Smooth gradients on iOS using CGShading

First, compare the two images below:
This project includes the class `JSTGradientView` which is a `UIView` subclass that can be used wherever a smooth gradient is needed.
This is a replacement for manually drawing a gradient using `CGGradient`. The class used `CGShading` internally instead.
To see why, look at the two images below:

![Smooth](http://jernejstrasner.com/images/2013-10-17/gradient_ps.png) ![Regular](http://jernejstrasner.com/images/2013-10-17/gradient_cg.png)

The first one is drawn using the class published here (JSTGradientView) with a slope factor of 2, the second one is drawn using a linear CGGradient. Guess which one designers usually draw in Photoshop? Yep, the first one.
The first one is drawn using `JSTGradientView` with an interpolation factor of 2, the second one is drawn using `CGGradient`.
Guess which one designers usually put in their designs? Yep, the first one. Most image editing software does a better job at interpolating colors than `CGGradient`
and to mimic that `JSTGradientView` was born.

Check out the code and comments for more.
Check out the code and sample app to see how the interpolation factor affects the gradient.

A full **Swift 2** version of the class is available in the branch [swift2](https://github.com/jernejstrasner/Smooth-Gradient/tree/swift2).

## Setup

### Carthage

Start by adding the following line to your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile).
```ruby
github "jernejstrasner/Smooth-Gradient" ~> 1.0
```
The run
```sh
carthage update
```
and add the built frameworks to your Xcode project.

Full instructions on installing dependencies with Carthage can be found in [Carthage's README](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application).

0 comments on commit 92bd4a5

Please sign in to comment.