Sobes.tech
Junior — Senior

What color will be output to the console

livecode

Task condition

The question is about which specific color will be displayed when outputting the backgroundColor property of a layer. Consider the following Swift code example, where we create a UIView, set its background, then change the background of its layer. After that, we set the view's background again and print the layer's background color to the console.

let view = UIView()
view.backgroundColor = .red

let layer = view.layer
layer.backgroundColor = UIColor.green.cgColor
view.backgroundColor = .red

print(view.layer.backgroundColor?.colorSpace as Any) // ?

What color will be printed?