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.
Fetch the three most prominent colors in an image.
Requirements
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 forPalette
.Manually
To manually install, simply copy Palette.swift into your project.
How To Use
A simplified overview:
Palette also provides a synchronous method call
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.