Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ashishkakkad8/657184064170128897d889ec1691e81d to your computer and use it in GitHub Desktop.
Save ashishkakkad8/657184064170128897d889ec1691e81d to your computer and use it in GitHub Desktop.
UIColorPickerViewController - iOS 14 - A view controller that informs your app about user interaction with the color picker.
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func btnColorPickerPressed(_ sender: Any) {
let colorPickerVC = UIColorPickerViewController()
colorPickerVC.delegate = self
present(colorPickerVC, animated: true) {
}
}
}
extension ViewController : UIColorPickerViewControllerDelegate {
func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) {
}
func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) {
self.view.backgroundColor = viewController.selectedColor
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment