i have sended a color name with a delegate from a different ViewController and the data recieves successfully(printed the right color). Then if I want to change the backroundcolor of the view itself then with that name that I received but it didn't work.
func sendColor(color: String) {
let colorLowercased = color.lowercased()
print(colorLowercased)
view.backgroundColor = UIColor(named: "\(colorLowercased)")
print(view.backgroundColor)
}
and the code execute
after changing the backgroundcolor is nil and the view is black
in the colorviewController here's my delegate function to send
@IBAction func colorPressed(_ sender: UIButton) {
let selectedColor = sender.currentTitle
if let delegate = delegate {
delegate.sendColor(color: selectedColor!)
}
_ = navigationController?.popViewController(animated: true)
}
btw im using swift 4.2