macColorPicker is a tiny, pure Swift library designed for macOS applications that allows you to let your users easily choose a color.
macColorPicker allows you to present the user with a preset range of colors to choose from. As the developer, you get to choose how these are formatted, how they look, and what happens when a user makes a selection.
If you want to give the user more control, you can also allow them to select a button that presents the NSColorPanel
.
macColorPicker is a subclass of NSView
so you can simply add ColorPicker like you would any other view, whether it be to your storyboard, XIB, or just in code.
Configuring ColorPicker's delegate
allows you to be notified when the ColorPicker view is about to be presented, when is has been presented, or when a user has selected a color.
ColorPicker.mov
To run the example project, clone the repo, and open the example Xcode Project in RichEditorExample.
macColorPicker supports macOS 10.12 and above.
macColorPicker is also available through Swift Package Manager. To install it, simply add the dependency to your Package.Swift file:
macColorPicker was previously available through CocoaPods and Carthage, however making the library available to all three Cocoapods, Carthage, and SPM (and functional to all three) was becoming troublesome. This, combined with the fact that SPM has seen a serious up-tick in adoption & functionality, has led me to remove support for CocoaPods and Carthage.
...
dependencies: [
.package(url: "https://github.com/will-lumley/macColorPicker.git", from: "1.3.0"),
],
targets: [
.target( name: "YourTarget", dependencies: ["macColorPicker"]),
]
...
William Lumley, [email protected]
macColorPicker is available under the MIT license. See the LICENSE file for more info.