导航栏改变高度 [英] Navigation Bar Changes Height

查看:38
本文介绍了导航栏改变高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将我的 UIViewController 从我以前的控制器推送到屏幕时,它会为更改设置动画.但是当它完成加载时,它会调整我的导航栏的大小,而跳跃的过渡让它看起来很糟糕.我怎样才能解决这个问题?我所做的只是将导航栏隐藏在 viewWillAppear 中的控制器 A 中,并在 viewDidLoad 中的控制器 B 中显示它.

When I push my UIViewController to the screen from my previous controller it animates the change. But when it finishes loading it resizes my navigation bar and the jumpy transition makes it look bad. How can I fix this? All I'm doing is hiding the navigation bar in Controller A in viewWillAppear and showing it in Controller B in viewDidLoad.

推荐答案

好的解决了.在控制器 B(我正在推送的视图控制器)的 viewDidLoad 中添加以下内容:

Ok solved it. In viewDidLoad of Controller B (the view controller I'm pushing) add the following:

UINavigationBar *navigationBar = self.navigationController.navigationBar;

[navigationBar setBackgroundImage:[UIImage new]
                   forBarPosition:UIBarPositionAny
                       barMetrics:UIBarMetricsDefault];

[navigationBar setShadowImage:[UIImage new]];

然后在您的 UIViewController 的 XIB 中对导航栏进行高度约束并将其设置为 68(通过测试实际行似乎落在 68 和 69 之间).丝般顺滑.

Then in your UIViewController's XIB make a height constraint on the navigation bar and set it to 68 (from testing the actual line seems to fall in between 68 and 69). Smooth as silk.

如果有人有更好的想法,请添加.我将不得不修改此屏幕旋转解决方案,因此它并不完美.

edit: If anyone has any better ideas please add them. I'll have to modify this solution for screen rotation so its not perfect.

这篇关于导航栏改变高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆