菜鸟教程小白 发表于 2022-12-11 19:48:16

ios - 当 isTranslucent = False (Swift 3) 时,导航栏会展开


                                            <p><p>我有一个带有搜索栏的表格 View 。但是,当我单击搜索栏时,导航栏似乎会展开并在其下方创建一个空白区域。但是,这只发生在 <code>self.navigationController?.navigationBar.isTranslucent = false</code> 但是当我评论这一行时,空白永远不会出现。此外,只有当我按下搜索栏时才会出现白条。以下是一些图片供引用:</p>

<ol>
<li>这是我不按搜索栏的时候。</li>
<li>然后,当我按下搜索栏时,其下方会出现一个空白。</li>
<li>然后当我取消搜索栏时,导航栏和搜索栏之间会出现空白。</li>
</ol>

<p> <a href="/image/fTv7l.png" rel="noreferrer noopener nofollow"><img src="/image/fTv7l.png" alt="This is when I don&#39;t press the search bar."/></a> </p>

<p> <a href="/image/N2dYy.png" rel="noreferrer noopener nofollow"><img src="/image/N2dYy.png" alt="Then when I press the search bar a white space appears under it."/></a> </p>

<p> <a href="/image/M2bth.png" rel="noreferrer noopener nofollow"><img src="/image/M2bth.png" alt="And then when I cancel out of the search bar the white space is between the navigation bar and the search bar."/></a> </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>在<code>viewDidLoad</code>中加入这一行:</p>

<pre><code> self.automaticallyAdjustsScrollViewInsets = false
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 当 isTranslucent = False (Swift 3) 时,导航栏会展开,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/44373419/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/44373419/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 当 isTranslucent = False (Swift 3) 时,导航栏会展开