Skip to content

yippeeapp/UIImageColors

 
 

Repository files navigation

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.

preview

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.detailColor

UIImage 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

About

iTunes style color fetcher for UIImage.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%