https://github.com/zhiyongzou/hexcolor
A convenient way to convert hex strings to UIColor or NSColor
https://github.com/zhiyongzou/hexcolor
cocoapods convenient extension hex hexcolor ios mac nscache nscolor swift uicolor watchos
Last synced: 3 months ago
JSON representation
A convenient way to convert hex strings to UIColor or NSColor
- Host: GitHub
- URL: https://github.com/zhiyongzou/hexcolor
- Owner: zhiyongzou
- License: mit
- Created: 2020-09-21T01:54:36.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-02-20T06:20:13.000Z (over 3 years ago)
- Last Synced: 2025-08-03T15:04:05.866Z (3 months ago)
- Topics: cocoapods, convenient, extension, hex, hexcolor, ios, mac, nscache, nscolor, swift, uicolor, watchos
- Language: Swift
- Homepage:
- Size: 33.2 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HexColor


[](https://github.com/zhiyongzou/IRHexColor/blob/master/LICENSE)

A convenient way to convert hex strings to UIColor or NSColor. HexColor support RGB 、ARGB and RGBA hex strings.
In addition, **[HexColor will cache hex color for reusing which can improve performance.]()**
# Examples
RGB hex string
```swift
let red = UIColor.hexColor("FF0000")
let green = UIColor.hexColor("#00FF00")
let blue = UIColor.hexColor("0000FF")
```
ARGB hex string
```swift
let aquaAlpha = UIColor.hexColor("99D4F2E7")
let yellowAlpha = UIColor.hexColor("88FFFF00")
```
RGBA hex string
```swift
let aquaAlpha = UIColor.hexColor("D4F2E799", type: .ARGB)
let yellowAlpha = UIColor.hexColor("FFFF0088", type: .ARGB)
```
Set Color cache count limit
```swift
// default is 100
UIColor.cacheCountLimit = 200
```
# Installation
## CocoaPods
```bash
pod 'IRHexColor'
```
## Manually
Drag and drop HexColor.swift file into your project