I tried to change the color of the buttons of my application by creating a color using the sliders to select the values of red, green, blue and alpha. So I created a variable containing the color created by the user.
ViewController are buttons. ChangeColors is an RGB slider system.
import UIKit import Foundation var buttonColor = UIColor() class ViewController: UIViewController { @IBOutlet var tools: UIButton! @IBOutlet var custom: UIButton! @IBOutlet var support: UIButton! @IBOutlet var donate: UIButton! override func viewDidLoad() { super.viewDidLoad() tools.backgroundColor = buttonColor custom.backgroundColor = buttonColor support.backgroundColor = buttonColor donate.backgroundColor = buttonColor } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning()
The second code is the RGB Slider system code.
import Foundation import UIKit class ChangeColors: UIViewController { @IBOutlet var Red: UISlider! @IBOutlet var Green: UISlider! @IBOutlet var Blue: UISlider! @IBOutlet var Alpha: UISlider! override func viewDidLoad() { super.viewDidLoad()
But the application crashes immediately after opening it and receives the following error:
The application terminated due to the uncaught exception "NSInvalidArgumentException", reason: "*** -CGColor is not defined for UIColor; you must first convert the color space.
I really need some help. Thanks.
source share