Imported from Tumblr
I recently wanted to use the official brand colors in an app I’m working on. I really like the UIColor syntax for the built-in colors and thought it would be nice to be able to choose the appropriate brand color in a similar manner.
In Swift there is a very clean way to do this. Creating an extension of UIColor we can create some class functions that act just like the built-in colors.
I created a Swift file called UIColorExtensions and just added the class functions I wanted named after the brand color I wanted. Now, all the brand colors are available easily all over the project. And we have a single file for setting the colors that is easily transferrable between projects.
You can find this in the linked gist. gist.github.com/natebird/… #swift