Hi all
Im trying to understand how blocks work.
[UIView animateWithDuration:1 animations:^{
blueViewController.view.alpha = 0;
yellowViewController.view.alpha = 0;
}];
I would love to understand how they implemented this to make a transition. As i see it the block that updates the views’s alpha to 0 can only be executed and that would result in an instant update and not a animation?.
It would properly help me understand how blocks work if someone could explain to me how they might have implemented the function.
also i think its a bit wierd that i the closure created by the block only create readonly variables. How am i then able to change the alpha without defining it with the “_block” keyword? is the “_block” only required for scaler types? (int / float ect).
The magic is not the Block system, it just allows you to create and call anonymous functions. The magic is the Core Animation framework.
The basic is that all parameters are immediately applied, but instead of redrawing everything right away, Core Animation looks for the changes and applies them over the given animation duration.
Look into the Core Animation framework reference and the WWDC 2010 sessions 424 and 425 for deeper informations.