Skip to content

Instantly share code, notes, and snippets.

@ashishkakkad8
Created August 29, 2020 09:18
Show Gist options
  • Save ashishkakkad8/16ece44d6ad7ffc0fc2a5a075cd0dcff to your computer and use it in GitHub Desktop.
Save ashishkakkad8/16ece44d6ad7ffc0fc2a5a075cd0dcff to your computer and use it in GitHub Desktop.
UIColorWell - iOS 14 - A control that displays a color picker.
import UIKit
class ViewController: UIViewController {
var colorWell: UIColorWell!
override func viewDidLoad() {
super.viewDidLoad()
addColorWell()
}
func addColorWell() {
colorWell = UIColorWell(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
self.view.addSubview(colorWell)
colorWell.center = view.center
colorWell.title = "Select Color"
colorWell.addTarget(self, action: #selector(colorWellChanged(_:)), for: .valueChanged)
}
@objc func colorWellChanged(_ sender: Any) {
self.view.backgroundColor = colorWell.selectedColor
}
}
@neerav512
Copy link

I get this error message...
Argument of '#selector' does not refer to an '@objc' method, property, or initializer
I have already marked the function with @objc attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment