Get Updates By E-mail 

Article Written By:
Johann Dowa

Swift Library For Easily Generating Color Palettes From An Image

  •  
  •  
  •  
  •  
  •  

Earlier this year I mentioned a handy Swift library called Hue with a number of nice features such as easy creation of gradients.

Here’s an open source Swift library called UIImageColors from jathu that allows you to easily create a simple color palette from an image similar to how iTunes fetches colors based on an album cover.

UIImageColors features a very simple syntax, and this code example shows how to gather colors from an image:

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

Here is an image from a readme showing some images and the palettes generated from them:


UIImageColors

You can find UIImageColors on Github here.

A nice Swift library for easily creating color palettes based on an image.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments