OGeek|极客世界-中国程序员成长平台

标题: ios - UINavigationController 自定义模态过渡,导航栏太小 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 13:18
标题: ios - UINavigationController 自定义模态过渡,导航栏太小

我正在使用自定义转换以模态方式显示位于 UINavigationController 内的 UIViewController。我正在使用一个缩放过渡,它以较小的框架开始并以 UINavigationController 全屏结束。

    toView.transform = CGAffineTransformMakeScale(kInitialScale, kInitialScale);
    [containerView addSubview:toView];

    [UIView animateWithDuration:duration animations: ^{
        toView.transform = CGAffineTransformMakeScale(1.0, 1.0);
    } completion: ^(BOOL finished) {
        [transitionContext completeTransition:![transitionContext transitionWasCancelled]];
    }];

我的问题是 UINavigationController 是使用导航栏创建的,该导航栏不考虑状态栏(比应有的小),并且仅在达到其全屏尺寸时才适应(从 44 像素到 64 像素)。导航标题在动画结束时偏移。

知道如何避免标题的最终偏移并从一开始就创建具有良好导航栏大小的导航 Controller 吗?



Best Answer-推荐答案


在转换之前将 toView 添加到 containerView 就可以了。

关于ios - UINavigationController 自定义模态过渡,导航栏太小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27515419/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4