They are discouraged because there is a better, cleaner alternative
In this case all a block animation does is automatically wrap your animation changes (setCenter:
for example) in begin and commit calls so you dont forget. It also provides a completion block, which means you don't have to deal with delegate methods.
Apple's documentation on this is very good but as an example, to do the same animation in block form it would be
[UIView animateWithDuration:0.25 animations:^{
self.view.center = CGPointMake(self.view.center.x, self.view.center.y-moveAmount);
} completion:^(BOOL finished){
}];
Also ray wenderlich has a good post on block animations: link
Another way is to think about a possible implementation of block animations
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations
{
[UIView beginAnimations];
[UIView setAnimationDuration:duration];
animations();
[UIView commitAnimations];
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…