Skip to content

A convenient way to convert hex strings to UIColor or NSColor

License

Notifications You must be signed in to change notification settings

zhiyongzou/HexColor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HexColor

build CocoaPods Version License visitors

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

let red = UIColor.hexColor("FF0000")
let green = UIColor.hexColor("#00FF00")
let blue = UIColor.hexColor("0000FF")

ARGB hex string

let aquaAlpha = UIColor.hexColor("99D4F2E7")
let yellowAlpha = UIColor.hexColor("88FFFF00")

RGBA hex string

let aquaAlpha = UIColor.hexColor("D4F2E799", type: .ARGB)
let yellowAlpha = UIColor.hexColor("FFFF0088", type: .ARGB)

Set Color cache count limit

// default is 100
UIColor.cacheCountLimit = 200

Installation

CocoaPods

pod 'IRHexColor'

Manually

Drag and drop HexColor.swift file into your project