Latest 1.0.0
Homepage https://github.com/ios-studio/Mixer
License MIT
Platforms ios 8.0, requires ARC
Authors

Mixer Build Status codecov.io Carthage compatible

Centralize your color definitions in a CSV file & easily share them for people to edit.

Installation

Via Carthage:

Add the following your Cartfile:

For Swift 3:

github "ios-studio/Mixer" ~> 1.0.0

For Swift 2.x:

github "ios-studio/Mixer" ~> 0.1.2

Via CocoaPods:

Add the following your Podfile:

For Swift 3:

pod "Mixer", "~> 1.0.0"

For Swift 2.x:

pod "Mixer", "~> 0.1.2"

Default Setup

Mixer will look for a file named Colors.csv in the specified bundle or at the specified path. The contents of the file should look like this. It is important to keep the headers as shown, otherwise Mixer will not be able to read the file.

For the colors you’d like to use in your project, define a class which conforms to the protocol MixerColor. The only requirement of that protocol is that the object responds to the property name, so for example it could look like:

enum Color: String, MixerColor {
    case Blue = "Blue"
    case Red = "Red"

    var name: String { return rawValue }
}

Where "Blue" corresponds to the name of a color in the csv file.

Configuring

Mixer can be passed a MixerConfiguration object where you can specify another path to your colors file.

Using Mixer

Pass the bundle to initialize. Mixer will look up the Colors file in the bundle and cache it for subsequent initializations in the same process:

let bundle = Bundle(forClass: self.dynamicType)
let mixer = Mixer(bundle: bundle)

Typically, all you will then use is the colorFor method, which you can use in two ways:

Using your color definition

Remember the definition of Color from above? This is how to get a color according to your definitions:

let color = mixer.colorFor(Color.Blue)

Using a string

This is a convenience method to be able to use Mixer with @IBDesignable / @IBInspectable. Since @IBInspectable does not yet work with enum types, you can use the version of colorFor without a type check like so:

let color = mixer.colorFor("Blue")

For an example involving @IBDesignable, go to the wiki

Contributions

Yes please!

Latest podspec

{
    "name": "Mixer",
    "version": "1.0.0",
    "summary": "A tiny library helping to centralize color definitions",
    "homepage": "https://github.com/ios-studio/Mixer",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Beat Richartz": "[email protected]"
    },
    "source": {
        "git": "https://github.com/ios-studio/Mixer.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Mixer/**/*.swift",
    "requires_arc": true,
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This