Skip to content

Shade-Zepheri/Palette

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Latest Release Supported Platforms License SwiftPM Compatible Twitter

Fetch the three most prominent colors in an image.

Requirements

  • iOS 10.0+ | macOS 10.12+ (10.15 for Catalyst) | tvOS 10.0+
  • Xcode 11.0+ (For Swift Package Manager)

Integration

Swift Package Manager (Xcode 11+)

Palette utilizes Swift Package Manager as the main means for distribution.

To add Palette to your project, select File -> Swift Packages -> Add Package Dependency and enter Palette's repo's URL. Alternatively, you can add your GitHub account to Xcode and search for Palette.

Manually

To manually install, simply copy Palette.swift into your project.

How To Use

A simplified overview:

let image = UIImage(named: "thing1.png")

image.retrieveColorPalette { palette in
    backgroundView.backgroundColor = palette.primary
    mainLabel.textColor = palette.secondary
    secondaryLabel.textColor = palette.tertiary
}

Palette also provides a synchronous method call

public func retrieveColorPalette(quality: UIImageResizeQuality = .standard) -> UIImageColorPalette?

Both the async and sync methods can take an optional UIImageResizeQuality parameter that resizes the image in order to improve performance.

License

Palette is licensed under the MIT License.