Sobes.tech
Junior — Senior

How to bind a selector to a CALayer object

livecode

Task condition

It is necessary to find out how to bind a method selector to a layer (CALayer).

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

let containerLayer = containerView.layer
containerLayer.backgroundColor = UIColor.green.cgColor
containerView.backgroundColor = .red

print(containerView.layer.backgroundColor) // ?

self.addTarget(for: self, #selector(foo: 1))