导航栏下的空白 [英] White space under the navigation bar

查看:60
本文介绍了导航栏下的空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

self.navigationController.navigationBar.translucent = NO时,导航栏下方出现空白,如下:

When self.navigationController.navigationBar.translucent = NO, a white space occur under the navigation bar, like this:

我怎样才能删除它?

// From above example
(void)loadUI
{
    [self.countriesButton setBackgroundColor:[UIColor colorWithRed:(243/255.0) green:(178/255.0) blue:(128/255.0) alpha:1]];
    [self.countriesButton.layer setCornerRadius:10];
    [self.countriesButton setClipsToBounds:YES];

    /// set attributes for Navigation Bar
    self.navigationItem.title = @"Welcome"; // Title of Navigation Bar
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:(243/255.0) green:(178/255.0) blue:(128/255.0) alpha:1];
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};
    self.navigationController.navigationBar.translucent = NO;
}

推荐答案

我想谈谈我是如何解决这个问题的,因为它很容易而且运行良好.

Im gonna chime in how i solved this one since it was easy and worked well.

在您的故事板中,选择在不透明导航栏下获取空白的视图控制器.

In your storyboard select the view controller that is getting the whitespace under the opaque navbar.

然后转到属性检查器"->视图控制器"->扩展边缘"-> 选中在不透明条下"框

Then go to 'Attributes Inspector' -> 'View Controller' -> 'Extend Edges' -> Check the box that says 'Under Opaque Bars'

这篇关于导航栏下的空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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