Code Monkey home page Code Monkey logo

uiimagecolors's Introduction

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

uiimagecolors's People

Contributors

jathu avatar

Watchers

Chew Chit Siang avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.