How to disable automatic transparent tabBar in iOS 15

With Xcode 13 and the iOS 15 SDK there are important changes to UITabBar.

Published: Oct. 8, 2021
App Store

In similar fashion to how UINavigationBar is by default transparent on iOS 15 when there is no content behind it, the UITabBar works the same way. This might either be a nice visual refresh you get for free (since it is turned on by default once you build with Xcode 13) or it might cause a lot of issues for your app.

Much like with the navbar it was the latter for me. Thankfully the fix is not complicated and requires just a few lines of code.

Restoring pre-iOS 15 look

To restore iOS 14 and prior look, we need to use the UITabBarAppearance API, which was first introduced with iOS 13.

if #available(iOS 13.0, *) { 
    let tabBarAppearance: UITabBarAppearance = UITabBarAppearance() 
    tabBarAppearance.configureWithDefaultBackground() 
    tabBarAppearance.backgroundColor = UIColor.tabBarBackground 
    UITabBar.appearance().standardAppearance = tabBarAppearance 

    if #available(iOS 15.0, *) { 
        UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance 
    } 
} 

In the app I was fixing, I needed the to do these two if #available to fix the tabBar on both iOS 15 and prior versions when built with Xcode 13. It is possible that for your app, only setting all these properties for iOS 15 will work fine.

The behavior is same as with the navbar. If we set the scrollEdgeAppearance to be the same as standardAppearance that will turn off the automatic content detection and stops turning the control transparent when there isn't content behind it.

Note that UIColor.tabBarBackground is custom color.

I just want to add that the transparent tabBar actually looks quite nice and we are using this design in one of our apps even on older iOS. So if you have extra time, you can experiment instead with fixing it in a way that it will stay transparent.

Filip Němeček profile photo

WRITTEN BY

Filip Němeček @nemecek_f@iosdev.space

iOS blogger and developer with interest in Python/Django. Want to see most recent projects? 👀

iOS blogger and developer with interest in Python/Django. Want to see most recent projects? 👀