It's "easy" to KVO a value in Swift3, using the technique in this great post...
https://stackoverflow.com/a/25219216/294884
How do I KVO the alpha of a UIView?
Goal: imagine a screen with a small view V. Screen has a large table view. Each cell has a small view CV.
I want each CV to follow1 the alpha of V, actually during an animation of the alpha of V.
(The only real alternate I can think of is to CADisplayLink the cells and poll the alpha of V, which kind of sucks.)
1Reason for that? It's the only way to sync alpha changes across cells.
Note Just as Rob explains below, in fact the alpha of a layer does not animate. (It just sets "instantly" to the new value at the beginning of an animation.) In fact you have to follow the presentation layer. Here's an example of the converse process, pulling it from where you want every draw
let d = CADisplayLink(target: self, selector: #selector(ThisClassName.updateAlpha))
d.add(to: RunLoop.current, forMode: RunLoopMode.commonModes)
func updateAlpha() {
let a = leader.layer.presentation()?.value(forKey: "opacity") as! CGFloat
follower.alpha = a
}