1

我已将UIColorPickerViewController添加到我的代码中,如下所示:

@IBAction func colorPickerButtonTapped() {
    let colorPicker = UIColorPickerViewController()
    colorPicker.delegate = self
    present(colorPicker, animated: true, completion: nil)
}

func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) {
    // view.backgroundColor = viewController.selectedColor
}

func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) {
    // view.backgroundColor = viewController.selectedColor
}

有没有办法可以自定义用户可以选择的颜色?

例如,如果我想让我的用户只选择灰度值,或者只从我的应用调色板中选择某些特定颜色,那么 UIColorPickerViewController 是否可以实现?

4

0 回答 0