Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable animation for code nested in a UIView animation block?

There's a method which is called inside an animation block by a third party API. In that method I'm supposed to build some subviews. But in this case I don't want animation to happen when constructing the subviews.

Is there a way of saying "[UIView dontAnimateFromHere] ... [UIView nowYouMayAnimateAgain]"?

like image 996
openfrog Avatar asked Sep 25 '11 23:09

openfrog


1 Answers

Yes indeed, there is such a way. It's like this:

[UIView setAnimationsEnabled:NO];
// Animations happen here
[UIView setAnimationsEnabled:YES];

...this will disable both UIView animations triggered via blocks and animations triggered using the old begin/end methods.

That said, I'm assuming your third party library is pre-compiled otherwise you could modify the source directly: it is of course possible it's doing something weird and animating in another way, so your mileage may vary with this solution.

This won't disable the changes being made in the animation blocks: they'll simple happen immediately. Otherwise you'd risk bad things happening since your third party API would be making assumptions about where views might be that weren't true.

like image 194
lxt Avatar answered Sep 28 '22 02:09

lxt