Culore
Named color presets for UIColor and NSColor, implemented in Swift. Supports over 300 officially defined colors!
Usage
Import into your project like so:
import Culore
Since Culore extends UIColor and NSColor, you must import UIKit or Cocoa in order to make use of it.
// iOS, tvOS, and watchOS
import UIKit
// macOS
import Cocoa
iOS, tvOS, and watchOS
let newColor = UIColor.culore("orange")
macOS
let newColor = NSColor.culore("orange")
Colors
Finding Colors
Visit one of Wikipedia's color variation pages (i.e. shades of orange) or the Culore supported color listing here, and find a color you like.
Entering Colors
Generate a color by supplying its name as a string literal to the .culore() method, which extends UIColor/NSColor.
let newColor = UIColor.culore("orange")
⚠️ ESSENTIAL ⚠️
- Ignore punctuation and parentheses.
orange (pantone) => orange pantone
hooker's green => hookers green
- Separate words in a color's name with a space, underscore, or dash.
uranian blue == uranian-blue == uranian_blue
- Remove spaces or dashes from the name if order matters.
blue-green => bluegreen
green-blue => greenblue
- Replace accented characters with their closest non-accented equivalent.
café noir => cafe noir
Notes
- You can supply a color name out of order.
UIColor.culore("pantone orange") == UIColor.culore("orange pantone")
- Case doesn't matter.
sky blue == SkY bLuE == SKY BLUE
Unsupported Colors
Not all named colors are supported; in these cases, Culore returns nil. Always check your colors before using them:
if let newColor = UIColor.culore("orange") {
myLabel.textColor = newColor
}
Future updates will add support for more colors as they are vetted and tested.
Installation
CocoaPods
To integrate Culore into your Xcode project using CocoaPods, specify it in your Podfile
:
pod 'Culore'
and run pod install
.
Requirements
- iOS 9.0+, tvOS 9.0+, watchOS 2.0+, or macOS 10.9+
- Swift 5.0+
- CocoaPods
License
MIT license