Animation Block Exception

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
...
[UIView commitAnimations];

For example, I need to animate the width of the frame conditionally, along with the other other changes that are required. The reason I cannot get the code out of this block is because there is a function call inside the block. How can I exclude some operations from the animation block?

+3
source share
2 answers

Checkout setAnimationsEnabled:

[UIView beginAnimations:@"Ani" context:NULL];
[UIView setAnimationDuration:1.0];
  // some animations
[UIView setAnimationsEnabled:NO];
  // animations disabled (put exclusions here)
[UIView setAnimationsEnabled:YES];
  // some more animations
[UIView commitAnimations];  
+8
source

Here is a block-based path:

[UIView performWithoutAnimation:^{
    view.frame = CGRectMake(...);
}];
0
source

Source: https://habr.com/ru/post/1756094/


All Articles