chameleon
Color framework for Swift & Objective-C (Gradient colors, hexcode support, colors from images & more).
A color library for iOS apps that makes it easy to pick good-looking color schemes, extract colors from images, and ensure text stays readable on any background color.
Chameleon is a color library for iOS apps, written in Objective-C with Swift support. Its main purpose is to make it easier for app developers to work with colors without spending time fiddling with raw red/green/blue numbers or struggling to find combinations that look good together.
The library offers a curated set of over 24 flat colors in both light and dark variants. Beyond individual colors, it can automatically generate color schemes from a single starting color, producing analogous, complementary, or triadic palettes. This means you pick one color and the library suggests others that work well with it.
Two features stand out. First, Chameleon can analyze any color and automatically determine whether text placed on top of it should be light or dark to stay readable. This removes guesswork when users can customize profile colors or when backgrounds vary. Second, it can extract a dominant color or full color scheme from an image, which is useful for matching an interface to a photo or product image.
The library also supports gradient colors applied in a single line of code to any view's background, text, or tint. There is an Xcode Storyboard add-on so the Chameleon colors appear in the visual color picker inside the design tool, and palettes can be exported to Photoshop and Sketch.
Installation is through CocoaPods or Carthage, the standard iOS dependency managers. The project requires iOS 7 or higher for Objective-C and iOS 8 or higher for Swift, with Xcode 6.3 minimum. It is MIT-licensed and open to contributions.
Where it fits
- Automatically choose whether text should be light or dark based on a dynamic or user-chosen background color.
- Generate a complementary or triadic color palette from a single brand color for your app UI.
- Extract the dominant color from a product image and apply it as the navigation bar or background tint.
- Apply a gradient in one line of code to any button, label, or view background.