UIImageColors
iTunes 11 style color fetcher for UIImage. This is an almost identical port of Panic's OS X ColorArt for iOS Swift.
In other words, it fetches the most dominant and prominent colors.
Documentation
This is pretty simple to use:
let image = UIImage(named: "hello.png")
let colors = image.getColors()
backgroundView.backgroundColor = colors.backgroundColor
mainLabel.textColor = colors.primaryColor
secondaryLabel.textColor = colors.secondaryColor
detailLabel.textColor = colors.detailColorUIImage Methods
- getColors(scaleDownSize: CGSize) -> UIImageColors
Get an UIImageColors struct from the image. Use smaller sizes for better performance at the cost of quality colors. Use larger sizes for better color sampling and quality at the cost of performance.
- getColors() -> UIImageColors
Get an UIImageColors struct from the image. The default image scale down is 250px width, and the aspect ratio height.
- resize(newSize: CGSize) -> UIImage
Resize your image.
UIImageColors
UIImageColors simply contains four different UIColor.
- backgroundColor -> UIColor
- primaryColor -> UIColor
- secondaryColor -> UIColor
- detailColor -> UIColor
UIColor Methods
As a result of testing colors for certain properties, UIColor get's some cool extensions. The functions are self-explanatory.
- isDarkColor -> Bool
- isBlackOrWhite -> Bool
- isDistinct(compareColor: UIColor) -> Bool
- colorWithMinimumSaturation(minSaturation: CGFloat) -> UIColor
- isContrastingColor(compareColor: UIColor) -> Bool
License
Feel free to do whatever you want. Please include the original header in any modifications or redistributions.
June 2015 - Toronto

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

