I'm creating a simple Custom NSView
that allows the user to input 3 text fields each for R,G and B values respectively. I already referenced this question and answer set here - it only accounts up to Swift 2.0
. So, does anyone know the correct technique of obtaining this same effect in Swift 3.0
? I can't seem to get anything that I'm doing to work. I keep getting errors of all sorts.
Here's the current technique I'm using (This seems to work... BUT it won't account for the other 2 RGB
values, since it's used in the @IBAction
):
//viewDidLoad
RVCustomView.wantsLayer = true
@IBAction func redValue(_ sender: AnyObject) {
print(red.stringValue)
var rValue = 0
let str = red.stringValue
if let n = NumberFormatter().number(from: str) {
rValue = Int(CGFloat(n))
}
CustomNSView.layer?.backgroundColor = CGColor(red: rValue, green: 255, blue: 255, alpha: 255)
}