简体   繁体   English

当UITabbar是半透明的并且UIViewController没有延伸到tabbar后面时,uitabbar似乎覆盖了黑色视图

[英]When the UITabbar is Translucent and the UIViewController is not extended behind the tabbar, the uitabbar seems like covering a black view

这就是我要的 这是我的问题

The tabbar in first view is what I want. 第一个视图中的标签栏就是我想要的。 Because the second view isn't a scrollview, so I can't extend it to bottom by using self.edgesForExtendedLayout = UIRectEdge.Bottom . 因为第二个视图不是滚动视图,所以我无法使用self.edgesForExtendedLayout = UIRectEdge.Bottom将其扩展到底self.edgesForExtendedLayout = UIRectEdge.Bottom

It looks unacceptable. 这看起来令人无法接受。

And I don't want to set Translucent of uitabbar to false , it's not fancy. 而且我不想将uluabbar的Translucent设置为false ,这不是花哨的。

I try in another way: [[UITabBar appearance] setBarTintColor: [UIColor whiteColor]]; 我试着用另一种方式: [[UITabBar appearance] setBarTintColor: [UIColor whiteColor]];

It doesn't work. 它不起作用。 To make it looks more clear, I change the color to red. 为了使它看起来更清晰,我将颜色更改为红色。 And the last tabbar also looks like covering some black views. 最后一个标签栏看起来也像是覆盖了一些黑色视图。

好 好

Consider of the tabbar is translucent, what's the view under the UITabbar view? 考虑到tabbar是半透明的,UITabbar视图下的视图是什么?

This is the final answer of why it doesn't work when changing the tintcolor of bar. 这是更改条纹的tintcolor时无法正常工作的最终答案。 Because the view under UITabbar view is black. 因为UITabbar视图下的视图是黑色的。

Thanks to the Xcode awesome debugging function. 感谢Xcode非常棒的调试功能。 We could locate the view under UITabbar view easily. 我们可以轻松地在UITabbar视图下找到视图。

在此输入图像描述

It's UIWindow. 这是UIWindow。 So the solution is to simply change the window's backgroundColor to white. 所以解决方案是简单地将窗口的backgroundColor更改为白色。

I would say that adding this code in viewDidLoad of your viewController will solve your issue: 我会说在viewController的viewDidLoad中添加此代码将解决您的问题:

    edgesForExtendedLayout = .all
    extendedLayoutIncludesOpaqueBars = true

Plus you can keed your tabBar translucent and not set any background color. 另外,您可以将tabBar半透明状态而不设置任何背景颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM