Skip to content
This repository was archived by the owner on Sep 17, 2022. It is now read-only.

More usage patterns

Beat edited this page Feb 7, 2016 · 2 revisions

In order to avoid shotgun surgery in the event you may want to change usage of mixer, write an adapter:

class ColorAdapter {
   private let mixer = Mixer(bundle: NSBundle(forClass: ColorAdapter.self))
   
   func colorFor(color: String) -> UIColor? {
       return mixer.colorFor(color)
   }
}

If you're a fan of extensions, here's how to extend UIColor:

extension UIColor {
    init(withName name: String) {
        guard let colorWithName = ColorAdapter().colorFor(name) else { return nil }
        self.init(CIColor: colorWithName.CIColor)
    }
}
Clone this wiki locally