Swift的随机颜色生成器:RandomColorSwift
ne3g
10年前
randomColor.js的一个Swift移植版。这个库可用于在iOS or OSX中生成诱人的随机颜色。
查看示例:demo and site。
// Returns a UIColor or NSColor object for an attractive color let color = randomColor() // Returns an array of ten green colors let greenColors = randomColorsCount(10, hue: .Green) // Returns a color for light blue let lightBlurColor = randomColor(hue: .Blue, luminosity: .Light) // Returns a color for a 'truly random' color let randomColor = randomColor(hue: .Random, luminosity: .Random) // Returns an array of ten dark pink colors let darkPinkColors = randomColorsCount(10, hue: .Pink, luminosity: .Dark) // Returns an array of twenty colors at hue of 120 let colors = randomColorsCount(20, hue: .Value(120), luminosity: .Random)