/SwiftyColor

🎨 The most sexy way to use colors in Swift.

Primary LanguageSwiftMIT LicenseMIT

SwiftyColor

Swift CocoaPods CI

The most sexy way to use colors in Swift. Both compatible with iOS and macOS.

Color from Hex int

//RGB
let color = 0x123456.color
//ARGB
let colorWithAlpha = 0xFF123456.color

Color from Hex string color code

//#RGB
let color = "#123456".color
//#ARGB
let colorWithAlpha = "#FF123456".color

Alpha Operator

Use infix operator ~.

let transparent = 0x123456.color ~ 50%
let red = UIColor.red ~ 10%
let float = UIColor.blue ~ 0.5 // == 50%

Percent Operator

let view = UIView()
view.alpha = 30% // == 0.3

License

SwiftyColor is under MIT license. See LICENSE file for more information.