1. <i id='OZJD2'><tr id='OZJD2'><dt id='OZJD2'><q id='OZJD2'><span id='OZJD2'><b id='OZJD2'><form id='OZJD2'><ins id='OZJD2'></ins><ul id='OZJD2'></ul><sub id='OZJD2'></sub></form><legend id='OZJD2'></legend><bdo id='OZJD2'><pre id='OZJD2'><center id='OZJD2'></center></pre></bdo></b><th id='OZJD2'></th></span></q></dt></tr></i><div id='OZJD2'><tfoot id='OZJD2'></tfoot><dl id='OZJD2'><fieldset id='OZJD2'></fieldset></dl></div>
      1. <small id='OZJD2'></small><noframes id='OZJD2'>

      2. <tfoot id='OZJD2'></tfoot>
        <legend id='OZJD2'><style id='OZJD2'><dir id='OZJD2'><q id='OZJD2'></q></dir></style></legend>

          <bdo id='OZJD2'></bdo><ul id='OZJD2'></ul>

        如何使 UINavigationBar 背景透明?

        时间:2023-06-12

          • <bdo id='ZoIuY'></bdo><ul id='ZoIuY'></ul>
          • <i id='ZoIuY'><tr id='ZoIuY'><dt id='ZoIuY'><q id='ZoIuY'><span id='ZoIuY'><b id='ZoIuY'><form id='ZoIuY'><ins id='ZoIuY'></ins><ul id='ZoIuY'></ul><sub id='ZoIuY'></sub></form><legend id='ZoIuY'></legend><bdo id='ZoIuY'><pre id='ZoIuY'><center id='ZoIuY'></center></pre></bdo></b><th id='ZoIuY'></th></span></q></dt></tr></i><div id='ZoIuY'><tfoot id='ZoIuY'></tfoot><dl id='ZoIuY'><fieldset id='ZoIuY'></fieldset></dl></div>
              <tbody id='ZoIuY'></tbody>

          • <tfoot id='ZoIuY'></tfoot>
            1. <legend id='ZoIuY'><style id='ZoIuY'><dir id='ZoIuY'><q id='ZoIuY'></q></dir></style></legend>

                • <small id='ZoIuY'></small><noframes id='ZoIuY'>

                • 本文介绍了如何使 UINavigationBar 背景透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  首先,我已经在

                  我正在使用(在 viewDidLoadviewWillAppear: 中都试过):

                  [self.navigationController.navigationBar setBackgroundImage:[UIImage new]forBarMetrics:UIBarMetricsDefault];self.navigationController.navigationBar.shadowImage = [UIImage new];self.navigationController.navigationBar.translucent = YES;self.navigationController.view.backgroundColor = [UIColor clearColor];

                  我明白了:

                  灰色状态栏背景,完全白色的导航栏与状态栏不融合,然后视图开始.其他问题答案"中的所有解决方案"对我来说都产生了相同的结果.

                  我也尝试设置 self.edgesForExtendedLayout = UIRectEdgeNone;self.edgesForExtendedLayout = UIRectEdgeAll; 但这也没有任何影响.

                  如何让我的导航栏透明而不弄乱一切?

                  更新: 按照 Warif Akhand Rishi 的回答,我已将 self.navigationController.view.backgroundColor = [UIColor clearColor]; 更改为 self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];,现在我得到了一个灰色的、统一的状态/导航栏,但仍然不透明:

                  更新 2:我已经连接了视图调试器,灰色背景似乎来自视图层次结构的最深处,并且我的视图内容没有向上扩展.我用最新的代码再次尝试了 self.edgesForExtendedLayout = UIRectEdgeAll; 但仍然无济于事:

                  解决方案

                  好的,经过努力,我自己解决了问题.问题不止一个.这不是关于扩展边缘,而是关于行 self.navigationController.view.backgroundColor = [UIColor clearColor]; (必须是 self.navigationController.navigationBar.backgroundColor =[UIColor clearColor]; 正如 Warif Akhand Rishi 建议的那样)以及我的表格视图的剪辑子视图属性.我已经更改了该行并关闭了我的表格视图的剪辑,现在它可以按预期工作了.

                  First of all, I've seen all the answers at How to make UINavigationBar Transparent in IOS 8? Transparent UINavigationBar and Make UINavigationBar transparent.

                  They just don't seem to work for me.

                  My regular view controller (before trying to make the navigation bar transparent) doesn't have any issues:

                  I'm using (tried both in viewDidLoad and viewWillAppear:):

                  [self.navigationController.navigationBar setBackgroundImage:[UIImage new]
                                                                forBarMetrics:UIBarMetricsDefault];
                  self.navigationController.navigationBar.shadowImage = [UIImage new];
                  self.navigationController.navigationBar.translucent = YES;
                  self.navigationController.view.backgroundColor = [UIColor clearColor];
                  

                  I'm getting this:

                  Gray status bar background, completely white navigation bar which doesn't blend with the status bar, and then the view starts. All the 'solutions' at the other questions' answers' yield the same result for me.

                  I've also tried setting self.edgesForExtendedLayout = UIRectEdgeNone; or self.edgesForExtendedLayout = UIRectEdgeAll; but that also didn't have any impact.

                  How can I make my navigation bar transparent without messing up everything?

                  UPDATE: Following Warif Akhand Rishi's answer, I've changed self.navigationController.view.backgroundColor = [UIColor clearColor]; to self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];, now I'm getting a gray, unified status/navbar, but still not transparent:

                  UPDATE 2: I've hooked up the view debugger, and that gray background seems to come from deep down from the roots of view hierarchy, and my view's content is not extending up. I've tried self.edgesForExtendedLayout = UIRectEdgeAll; again with the latest code but still no avail:

                  解决方案

                  Okay, after struggling, I've solved the problem on my own. There was more than one problem. It wasn't about the extended edges, it was about the line self.navigationController.view.backgroundColor = [UIColor clearColor]; (which had to be self.navigationController.navigationBar.backgroundColor = [UIColor clearColor]; as Warif Akhand Rishi suggested) and also my table view's clip subviews property. I've changed that line and also turned off clipping of my table view and now it works as expected.

                  这篇关于如何使 UINavigationBar 背景透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:带有两个 NavigationController 链接协议的 splitViewController 下一篇:在 Xcode 中以编程方式按下 UITabBar 按钮

                  相关文章

                  1. <tfoot id='9z6gY'></tfoot>
                  2. <small id='9z6gY'></small><noframes id='9z6gY'>

                  3. <i id='9z6gY'><tr id='9z6gY'><dt id='9z6gY'><q id='9z6gY'><span id='9z6gY'><b id='9z6gY'><form id='9z6gY'><ins id='9z6gY'></ins><ul id='9z6gY'></ul><sub id='9z6gY'></sub></form><legend id='9z6gY'></legend><bdo id='9z6gY'><pre id='9z6gY'><center id='9z6gY'></center></pre></bdo></b><th id='9z6gY'></th></span></q></dt></tr></i><div id='9z6gY'><tfoot id='9z6gY'></tfoot><dl id='9z6gY'><fieldset id='9z6gY'></fieldset></dl></div>
                  4. <legend id='9z6gY'><style id='9z6gY'><dir id='9z6gY'><q id='9z6gY'></q></dir></style></legend>
                      • <bdo id='9z6gY'></bdo><ul id='9z6gY'></ul>