Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I exclude a piece of code inside a core animation block from being animated?

I have an core animation block where I call a method that will load a view controller. there is an custom transition between two view controllers happening. However, when the view controller builds up the interface, all this stuff is affected by core animation. Although it results in some interesting effects, I don't want that ;)

[UIView beginAnimations:@"jump to view controller" context:self];
[UIView setAnimationDuration:0.55];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

// some animated property-changes here...

[self loadViewControllerForIndex:targetIndex]; // everything that happens in this method shall not be animated

UIViewController *controller = [viewControllers objectAtIndex:targetIndex];
[controller viewWillAppear:YES];
[controller viewDidAppear:YES];

[UIView commitAnimations];

Unfortunately I can't move that part out of the block.

like image 236
Thanks Avatar asked Feb 28 '26 09:02

Thanks


1 Answers

You should be able to suppress animations for a section of the UIView animation block by wrapping that section in a CATransaction and disabling animations for it:

[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];    

// Changes to disable animation for here
[CATransaction commit];
like image 66
Brad Larson Avatar answered Mar 02 '26 23:03

Brad Larson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!