In short the nested animation allows to run 2 independent animations simultaneously. But what to do if I have a complex code which consists of both animated and non-animated code? I mean the following situation:
[UIView animateWithDuration:...
animations:^{
...//code1 - with animation
...//code2 - also contains code which shouldn't be animated
}];
Code2
looks like the calling of the following method:
- (void)someMethod {
...//code3 - without animation
[self someMethod2Animated:NO completion:^{
[self someMethod2Animated:YES completion:^{
NSLog(...);
}];
}];
}
Where someMethod2
executes the same code but maybe inside the animatedWithDuration:animations:completion:
depending on the given BOOL
variable.
If I run this code then I see that all the code parts are animated. I tried to set the durations of the code2
to zero but it has no effect (the code is still animated).
Could you suggest how to solve this issue without of rewriting all the code? I heared about some solutions like ReactiveCocoa
but it seems they are suitable for network/separate asynchronous requests only.
Edited
PromiseKit 2.0 allows to convert enclosed animation blocks to a sequence of blocks but it doesn't support iOS 7 I need.
The best solution I found out is RZViewActions. Advantages for my case:
operate with animations as with objects without nested blocks;
serial and parallel animations are "sequences" and "groups" which are objects too created from simple arrays of animations;
just take its demo, remove
[self.spinner startAnimating];
, run and click the screen multiple times. A lot of animations are performed simultaneously even without any special code (in case ofanimateWithDuration:
the next animation would kill the previous unfinished one).The second solution could be PromiseKit 2.0. It may be run under iOS 7 but it needs some magic to be added to the project.