In iOS, you can animate view objects using animation blocks:
[UIView animateWithDuration:1.0 animations:^{ firstView.alpha = 0.0; secondView.alpha = 1.0; }]
What we have here is a block of code that describes how the properties of the view will look after the animation is completed.
How it works?
I could understand (I think) if this was done using some declarative format, but from his point of view, the animation block is just an ordinary piece of code that is supposed to be executed, the results are checked, and then someone is transcoded into the actual lower level graphics code that performs the animation.
Is the block actually executed (or somehow reconstructed), and if so, when?
If this code is executed before the start of the animation, then how does the immediate reflection of changes in the properties of the reference view occur?
What happens if I put the code in a block that does not change the properties of the view, but does something else?
ios core-animation objective-c-blocks
Thilo
source share