iOS7 UINavigationController pushViewController动画
所以。 刚开始将我的IOS代码转换到IOS7时,遇到了一些问题。
  我有一个UINavigationController ,它有子ViewControllers,我使用pushViewController来显示下一个视图。  要用一组图像创建视差动画,如果自定义UINavigationController来为一组UIImageViews设置动画,并且我的子ViewController都具有self.backgroundColor = [UIColor clearColor]透明度。 
  自iOS7以来, UINavController通过部分移动当前视图控制器并在顶部推新视图控制器的方式更新了UINavController为其子视图vc的动画方式,我的视差动画看起来很糟糕。  我看到以前的VC移动一点,然后消失。  有什么办法可以恢复以前的UINavigationController pushViewController动画吗?  我似乎无法在代码中找到它。 
WelcomeLoginViewController* welcomeLoginViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"WelcomeLogin"];
    [self.navigationController pushViewController:welcomeLoginViewController animated:YES];    
即使尝试使用:
    [UIView animateWithDuration:0.75
                     animations:^{
                         [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                         [self.navigationController pushViewController:welcomeLoginViewController animated:NO];
                         [UIView setAnimationTransition:<specific_animation_form> forView:self.navigationController.view cache:NO];
                     }];
有没有人有任何线索?
  我设法通过为UINavigationController创建一个类别来解决新的转换类型。  在我的情况下,我需要将其恢复到旧的过渡样式,因为我有透明的viewController滑过静态背景。 
UINavigationController的+ Retro.h
@interface UINavigationController (Retro)
- (void)pushViewControllerRetro:(UIViewController *)viewController;
- (void)popViewControllerRetro;
@end
UINavigationController的+ Retro.m
#import "UINavigationController+Retro.h"
@implementation UINavigationController (Retro)
- (void)pushViewControllerRetro:(UIViewController *)viewController {
    CATransition *transition = [CATransition animation];
    transition.duration = 0.25;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    transition.subtype = kCATransitionFromRight;
    [self.view.layer addAnimation:transition forKey:nil];
    [self pushViewController:viewController animated:NO];
}
- (void)popViewControllerRetro {
    CATransition *transition = [CATransition animation];
    transition.duration = 0.25;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    transition.subtype = kCATransitionFromLeft;
    [self.view.layer addAnimation:transition forKey:nil];
    [self popViewControllerAnimated:NO];
}
@end
我有清晰的背景颜色和蹩脚的动画相同的问题,所以我用新的iOS7 API创建ViewController的自定义过渡。 您只需为您的导航控制器设置一个代表:
// NavigationController does not retain delegate, so you should hold it.
self.navigationController.delegate = self.navigationTransitioningDelegate;
只需将这些文件添加到您的项目:MGNavigationTransitioningDelegate。
我有一个问题,当UIViewController A执行一个pushViewController来推送UIViewController B时,推动动画停止在大约25%,停止,然后在剩下的路程中滑动B.
这个DID不会发生在iOS 6上,但是当我开始使用iOS 7作为XCode 5中的基础SDK时,就开始发生这种情况。
解决方案是,视图控制器B在其根视图上没有设置backgroundColor(根视图是viewController.view的值,通常在loadView中设置)。 在该根视图的初始化程序中设置backgroundColor可以解决问题。
我设法解决这个问题如下:
// CASE 1: The root view for a UIViewController subclass that had a halting animation
- (id)initWithFrame:(CGRect)frame
{
     if ((self = [super initWithFrame:frame])) {
          // Do some initialization ...
          // self.backgroundColor was NOT being set
          // and animation in pushViewController was slow and stopped at 25% and paused
     }
     return self;
}
// CASE 2: HERE IS THE FIX
- (id)initWithFrame:(CGRect)frame
{
     if ((self = [super initWithFrame:frame])) {
          // Do some initialization ...
          // Set self.backgroundColor for the fix!
          // and animation in pushViewController is no longer slow and and no longer stopped at 25% and paused
          self.backgroundColor = [UIColor whiteColor]; // or some other non-clear color
     }
     return self;
}
上一篇: iOS7 UINavigationController pushViewController animation
下一篇: Issue with horizontal scrollview inside a vertical scrollview in ios swift
