Controller的NavigationBar半透明属性设置为

Controller的NavigationBar半透明属性设置为

本文介绍了将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会导致额外的填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 18:34