ios - UIKIt - 删除状态栏但留下空间
<p><p>我知道如何删除状态栏,但这会自动将我的导航 Controller 及其导航栏捕捉到屏幕顶部。</p>
<p>如何移除状态栏但在屏幕顶部保留 20 像素的空间,以便我可以在该空间中放置自己的自定义 View 或窗口?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>创建自定义 UINavigationController 并覆盖 viewDidAppear</p>
<pre><code> - (void)viewDidAppear:(BOOL)animated
{
;
CGRect f = self.view.frame;
self.view.frame = CGRectMake(0,20,f.size.width,f.size.height-20);
//the custom view for replacing the status bar.
//you can add any custom subview you want
UIView *iv = [initWithFrame:CGRectMake(0,0,320,20)];
//assign a color with alpha less than 1.0 to make it translucent
iv.backgroundColor = ;
//remember to remove the iv when you don't need the navigation controller any more.
;
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - UIKIt - 删除状态栏但留下空间,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/22703303/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/22703303/
</a>
</p>
页:
[1]