UIColorPickerViewController
A view controller that manages the interface for selecting a color.
Declaration
@MainActor class UIColorPickerViewControllerOverview
UIColorPickerViewController provides a standard interface to select colors. Use this class instead of UIColorWell if you need more fine-grained control over the presentation.
[Image]
You typically present a UIColorPickerViewController as a popover:
// This example code appears in a subclass of UIViewController that conforms to
// UIColorPickerViewControllerDelegate.
func presentColorPicker() {
let colorPicker = UIColorPickerViewController()
colorPicker.title = "Background Color"
colorPicker.supportsAlpha = false
colorPicker.delegate = self
colorPicker.modalPresentationStyle = .popover
colorPicker.popoverPresentationController?.sourceItem = self.navigationItem.rightBarButtonItem
self.present(colorPicker, animated: true)
}You can also react to the color-selection change or the dismissal of the color picker by implementing the UIColorPickerViewControllerDelegate functions.