Created
August 29, 2020 09:18
-
-
Save ashishkakkad8/16ece44d6ad7ffc0fc2a5a075cd0dcff to your computer and use it in GitHub Desktop.
UIColorWell - iOS 14 - A control that displays a color picker.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.