I am currently building an application with Swift 3 and have defined a color in one ViewController with an let ... = ... statement and want to use this color in another ViewController too without defining it new. Any ideas?
2 Answers
also you could override the init function of the another ViewController, just like:
override init(withColor color: UIColor){
super.init(nibName: nil, bundle: nil);
}
then you could pass the color as the param:
let viewController = ViewController(withColor: UIColor.red);
but I think the best way is define it globally.