Generate NSColor / UIColor based on Swift String
Atsushi Nagase
I’ve published a Swift library ColorHash, that generates UIColor
and NSColor
based on given string.
import ColorHash
let str = "こんにちは、世界"
let saturation = CGFloat(0.30)
let lightness = CGFloat(0.70)
ColorHash(str, [saturation], [lightness]).color
This is a Swift port of a JavaScript library Color Hash.
Install
CocoaPods
pod 'ColorHash'
Carthage
github 'ngs/color-hash.swift'