Home > Software engineering >  Disable Tab Bar storyboard appearance setting programmatically
Disable Tab Bar storyboard appearance setting programmatically

Time:10-19

My app is required to be iOS 12.0 compatible and has a tab bar. Since iOS 13.0, the UITabBarAppearance() can be used to change its appearance. In the storyboard, I have Standard selected as Appearances within the attributes inspector. This makes the app crash when iOS 12.0 is used.

How can I disable standard appearance programmatically?

if #available(iOS 13.0, *) {
    // code for iOS >= 13.0
} else {
    // code for iOS < 13.0
    // Here I would like to disable the storyboard standard appearances
}

CodePudding user response:

You have configured the storyboard to use a class (UITabBarAppearance) that doesn't exist in iOS 12. So if the app runs on iOS 12, when storyboard loads: Kaboom.

If you want this app to be backward compatible, do things the other way: configure the tab bar the old way in the storyboard and then switch to the new way in your (conditional) code.

  • Related