Latest 1.0.0
License MIT
Platforms ios 6.0

Allows calculation of colors partway in between other colors


The demo/ folder contains a demo project showing
UIColor+Mix in use. Open and run it.


To mix between two colors, use the following:

[UIColor colorBetweenColor:… andColor:… percentage:…];

You can also mix between multiple colors, i.e. creating a complex
gradient. The gradient is configured similarly to in Photoshop: you
define a series of points along the gradient, and what the color is at
each point:

NSArray *gradient = @[
    @{@"position": @0.0,
        @"color": [UIColor redColor]},
    @{@"position": @0.5,
        @"color": [UIColor yellowColor]},
    @{@"position": @1.0,
        @"color": [UIColor greenColor]}
[UIColor colorAlongColors:gradient percentage:…];

Instead of defining a gradient in the code, you can define it in a
.plist file instead. Since UIColor is not available in .plists, you can
instead define a color as an Array of Numbers, where item 0 is red,
1 green, 2 blue, and 3 alpha:

plist screenshot


This class has been tested back to iOS 6.0.


This class is implemented by splitting the colors into components using
CGColorGetComponents(), then combining the components between the
different colors in the correct percentages.


This code is released under the MIT License. See the LICENSE file for details.

Latest podspec

    "name": "UIColor+Mix",
    "version": "1.0.0",
    "summary": "Allows calculation of colors partway in between other colors.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Josh Justice": "[email protected]"
    "platforms": {
        "ios": "6.0"
    "source": {
        "git": "",
        "tag": "1.0.0"
    "source_files": [
    "requires_arc": false

Pin It on Pinterest

Share This