Fetch the three most prominent colors in an image.
- iOS 10.0+ | macOS 10.12+ (10.15 for Catalyst) | tvOS 10.0+
- Xcode 11.0+ (For Swift Package Manager)
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
.
To manually install, simply copy Palette.swift into your project.
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.
Palette is licensed under the MIT License.