https://github.com/aleclarson/hex-kit
Convert hex triplets into UIColors and CGColors!
https://github.com/aleclarson/hex-kit
Last synced: 9 months ago
JSON representation
Convert hex triplets into UIColors and CGColors!
- Host: GitHub
- URL: https://github.com/aleclarson/hex-kit
- Owner: aleclarson
- License: mit
- Created: 2014-07-22T07:09:46.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-09-10T15:52:18.000Z (almost 11 years ago)
- Last Synced: 2024-12-30T01:15:27.643Z (over 1 year ago)
- Language: Swift
- Homepage:
- Size: 185 KB
- Stars: 68
- Watchers: 3
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

A simple library for converting a [hex triplet](http://en.wikipedia.org/wiki/Web_colors#Hex_triplet) (represented by a `String`) into a `UIColor` or `CGColor`!
```Swift
let myUIColor = "#FFFFFF".UIColor
let myCGColor = "#FFFFFF".CGColor
```
Specifying the color's `alpha` is very simple.
```Swift
let myUIColor = "#FFFFFF".UIColor(0.5)
```
Abbreviations for colors are allowed and typing a hash `#` is optional.
Here are the supported formats:
```Swift
"#123456"
"123456"
"#123" // Represents "#112233"
"123"
"#12" // Represents "#121212"
"12"
"#F" // Represents "#FFFFFF"
"F"
```
Just add the `Hexes.swift` file to your project, and you're good to go! Enjoy!