When I turn on the UISwitch I try to make it hide the background Image but I get the error: Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value. What am I doing wrong? when it was on the main storyboard it worked fine, but when on the settings storyboard it doesn't.
Code:
@IBAction func switchBackground(_ sender: UISwitch) {
if (sender.isOn == true) {
Background!.isHidden = false
amountDue.textColor = UIColor.white
amountMoney.textColor = UIColor.white
amountPeople.textColor = UIColor.white
}else {
Background!.isHidden = true
amountDue.textColor = UIColor.black
amountMoney.textColor = UIColor.black
amountPeople.textColor = UIColor.black
amountDueText.textColor = UIColor.black
amountPeopleText.textColor = UIColor.black
amountMoneyText.textColor = UIColor.black
}
}