使用UINavigationController进行iOS 7自定义当前转换

我正在使用iOS 7自定义转换来呈现UINavigationController.
但有一个问题.虽然它的动画,导航栏的大小只有44个点.完成动画后,导航控制器发现有状态栏,因此状态栏增加了20个点.

我的问题是,是否有可能在其动画时将导航栏设置为64磅,因此在完成动画时它不会再改变.

在这里查看更多细节Custom View Transitions

这是我的自定义动画代码

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext{

    UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];

    CGRect finalFrame = [transitionContext finalFrameForViewController:toViewController];

    UIView *containerView = [transitionContext containerView];

    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    toViewController.view.frame = CGRectOffset(finalFrame,screenBounds.size.height);
    [containerView addSubview:toViewController.view];

    NSTimeInterval duration = [self transitionDuration:transitionContext];

    [UIView animateWithDuration:duration delay:0.0 usingSpringWithdamping:0.6 initialSpringVeLocity:0.0 options:UIViewAnimationoptionCurveLinear animations:^{
        toViewController.view.frame = finalFrame;
    } completion:^(BOOL finished) {
        [transitionContext completeTransition:YES];
    }];
}

更新:有人解决了这个问题.但非常hacky.
将toViewController.view添加到containerView后添加代码.

if ([toViewController isKindOfClass:[UINavigationController class]]) {
    UINavigationController* navigationController = (UINavigationController*) toViewController;
    UINavigationBar* bar = navigationController.navigationBar;
    CGRect frame = bar.frame;
    bar.frame = CGRectMake(frame.origin.x,frame.origin.y + 20.0f,frame.size.width,frame.size.height);
}

有更好的方法吗?

解决方法

我有同样的问题,并解决了在设置此框架之前将t​​oViewController添加到容器.

反转如下的行:

[containerView addSubview:toViewController.view];
toViewController.view.frame = CGRectOffset(finalFrame,screenBounds.size.height);

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...