如何排除核心动画块中的一段代码不被动画?

Tha*_*nks 3 iphone cocoa-touch core-animation uikit

我有一个核心动画块,我调用一个方法来加载一个视图控制器.两个视图控制器之间发生了自定义转换.但是,当视图控制器构建界面时,所有这些东西都会受到核心动画的影响.虽然它会产生一些有趣的效果,但我不希望这样;)

[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];
Run Code Online (Sandbox Code Playgroud)

不幸的是,我不能将那部分移出街区.

Bra*_*son 10

您应该能够通过将该部分包装在CATransaction中并为其禁用动画来抑制UIView动画块的某个部分的动画:

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

// Changes to disable animation for here
[CATransaction commit];
Run Code Online (Sandbox Code Playgroud)