2021年1月23日星期六

How to change colors of two things with UIColorPickerViewController

I would like to change two colors (icon and background) with UIColorPickerViewController.

Now I can change the color of the icon. But I need to change the color of the background too.

However, I have no idea how to separate the extension part.

Currently, my code is as follows;

@IBAction func btnColorPickerPressed(_ sender: Any) {      let colorPickerVC = UIColorPickerViewController()      colorPickerVC.delegate = self      present(colorPickerVC, animated: true) {      }  }    @IBAction func bgColorPickerPressed(_ sender: Any) {      let colorPickerVC = UIColorPickerViewController()      colorPickerVC.delegate = self      present(colorPickerVC, animated: true) {      }  }  extension ViewController : UIColorPickerViewControllerDelegate {  func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) {      showImage()        }    func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) {      iconColor = viewController.selectedColor    }  

}

https://stackoverflow.com/questions/65866207/how-to-change-colors-of-two-things-with-uicolorpickerviewcontroller January 24, 2021 at 09:05AM

没有评论:

发表评论