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