Skip to content

Instantly share code, notes, and snippets.

@Jesse-calkin
Created March 23, 2016 19:46
Show Gist options
  • Save Jesse-calkin/96f3e74a353f9183f5cb to your computer and use it in GitHub Desktop.
Save Jesse-calkin/96f3e74a353f9183f5cb to your computer and use it in GitHub Desktop.
Color Management

Color Management

Base Colors

public struct Colors {
    public static let blue1 = UIColor(red: 0.0, green: 0.0, blue: 1.0, alpha: 1.0)
    public static let blue2 = UIColor(red: 0.0, green: 0.4, blue: 1.0, alpha: 1.0)
    public static let blue3 = UIColor(red: 0.1, green: 0.0, blue: 1.0, alpha: 1.0)
    public static let blue4 = UIColor(red: 0.2, green: 0.2, blue: 1.0, alpha: 1.0)
}

Semantic Names

extension Colors {
    public static var navbarBlue: UIColor { return Colors.blue1 }
    public static var subnavBlue: UIColor { return Colors.blue3 }
}

Example Usage

view.backgroundColor = Colors.navbarBlue

Class specific colors

@IBDesignable class SomeView: UIView {
...
    struct Colors {
        static let foregroundBlue = SomeProject.Colors.blue2
    }
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment