简体   繁体   中英

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 .

It looks unacceptable.

And I don't want to set Translucent of uitabbar to false , it's not fancy.

I try in another way: [[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?

This is the final answer of why it doesn't work when changing the tintcolor of bar. Because the view under UITabbar view is black.

Thanks to the Xcode awesome debugging function. We could locate the view under UITabbar view easily.

在此输入图像描述

It's UIWindow. So the solution is to simply change the window's backgroundColor to white.

I would say that adding this code in viewDidLoad of your viewController will solve your issue:

    edgesForExtendedLayout = .all
    extendedLayoutIncludesOpaqueBars = true

Plus you can keed your tabBar translucent and not set any background color.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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