Latest 8.0
License MIT
Platforms ios 9.0


The purpose of RainbowColors library is to simplify common tasks with colors in iOS, which makes implementation of colorful UI designs easier. Absolutely compatible with native iOS SDK.

How To Get Started

  • Copy content of RainbowColors folder to your project.


  • Use RainbowColors cocoapod


  • iOS 9 and later
  • Xcode 9 and later
  • Swift 4


Color Initialization

The common expression for color in RGB system is #123456. Another variety of this expression looks like #123 which is equivalent to #112233. The same time, iOS SDK doesn’t support those expressions above and requires to use CGFloat values for red, green, blue and alpha component in constructor of UIColor class. Not comfortable enough, right?

RainbowColors has a solution for the problem described above, so instead of this

let grayColor = UIColor(red: 51.0 / 255.0, green: 51.0 / 255.0, blue: 51.0, alpha: 255.0)

you can simply write this

let grayColor = UIColor(hexString: "#333333")

or this

let grayColor = UIColor(hexString: "#333")

or even this

let grayColor = UIColor(hexString: "333")

As you can see in last example, sharp symbol is optional. Hex string will be parsed correctly with or without sharp prefix.

RainbowColors supports both RGB and RGBA color systems, so you can also add alpha component to expression:

let grayColorWithSmallTransparency = UIColor(hexString: "#333333dd") // {51, 51, 51, 221}
let halfTransparentGrayColor = UIColor(hexString: "#3338") // {51, 51, 51, 136}
let almostTransparentGrayColor = UIColor(hexString: "#33333310") // {51, 51, 51, 16}

If hex string has wrong format, nil will be returned instead of color.

Brand Colors

Sometimes you don’t know which colors are good enough for your project. But you don’t need to be a professional designer, because you can reuse popular color schemes used by well-known services. RainbowColors has extendable collection of brand colors. All that you need is to write:

let color =


let color =

Of course, you are not limited to make any operations with those colors:

let flickrPinkWithHalfTransparency =

To see full collection of available brands, just type in Xcode UIColor.Brands. and you will see output like this:

Available Brands

Another way to check available brands is to take a look at BrandColorCollection.swift file.


RainbowColors is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "RainbowColors",
    "version": "8.0",
    "summary": "Colorful programming.",
    "description": "This library simplifies work with colors in Swift.",
    "homepage": "",
    "screenshots": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Igor Matyushkin": "[email protected]"
    "social_media_url": "",
    "platforms": {
        "ios": "9.0"
    "source": {
        "git": "",
        "tag": "8.0"
    "source_files": [
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This