将NavigationController的NavigationBar半透明属性设置为false会导致额外的填充 [英] Setting NavigationController's NavigationBar translucent property to false causes extra padding

查看:89
本文介绍了将NavigationController的NavigationBar半透明属性设置为false会导致额外的填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在NavigationController的NavigationBar(通过编程方式或通过StoryBoard)上设置translucent = false属性时,根内容视图顶部似乎有多余的填充.

There appears to be extra padding at the top of the root content view when the translucent = false property is set on the NavigationController's NavigationBar (programatically or via the StoryBoard).

我尝试过调整滚动视图的插图,但无济于事. translucent = true不会导致此问题.

I've tried adjusting the scroll view insets but to no avail. translucent = true doesn't cause this problem.

有什么想法为什么会发生这种情况以及最简单的解决方法是什么?

Any ideas why this is happening and what the easiest way to resolve it is?

推荐答案

啊哈-到最后. 使用半透明导航栏时,您需要确保在所有视图控制器上将adjusts scroll view insetsextend edges under opaque bars都设置为true.

Ah-ha - got there in the end. When not using a translucent navigation bar you need to ensure that both adjusts scroll view insets and extend edges under opaque bars are set to true on all your view controllers.

以下是StoryBoard设置:

Here are the StoryBoard settings:

这篇关于将NavigationController的NavigationBar半透明属性设置为false会导致额外的填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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