I'm trying to use Chameleon to get analogous colors. The returned array of colors is not nil, each of the 5 elements are also not nil. However the code "tintView.backgroundColor = color" results in "Fatal error: Unexpectedly found nil while unwrapping an Optional value". The first picture shows the code and the non-nil 5 element array returned from a call to Chameleon. The 2nd picture shows the variable as copied from the global array (it's missing data)
I've tried setting Chameleon to use Swift 4 as well as Swift 4.2. No difference. I'm currently targeting iPhone 7 running IOS 11.4 What am I missing? Shouldn't this simply work?
Pertinent part of Globals.swift:
static var companionColors = ColorSchemeOf(.analogous, color: UIColor.flatYellowDark, isFlatScheme: true)
static var complimentryColor = UIColor(complementaryFlatColorOf:selectedColor)
static var initialColorName = "Yellow"
static var selectedColor = UIColor.flatYellowDark {
didSet {
companionColors = ColorSchemeOf(.analogous, color: selectedColor, isFlatScheme: true)
complimentryColor = UIColor(complementaryFlatColorOf:selectedColor)
}
}
CommonViewController:
class CommonViewController: UIViewController {
@IBOutlet weak var canvas: UIImageView!
@IBOutlet weak var tintView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let color = Globals.companionColors[1]
tintView.backgroundColor = color
}
}
As mentioned the line 'tintView.backgroundColor = color' is throwing the error. Globals.companionColors contains 5 elements of type UIDeviceRGBColor* with RGBA values and a UIColor component. 'color' is an NSObject.