UITabBar items jumping on back navigation on iOS 12.1

  • A+

I have an iOS app with UITabBarController on a master screen, navigating to a detail screen hiding the UITabBarController with setting hidesBottomBarWhenPushed = true.

When going back to the master screen the UITabBarController does a strange "jump" as shown on this GIF:

UITabBar items jumping on back navigation on iOS 12.1

This happens only on iOS 12.1, not on 12.0 or 11.x.

Seems like an iOS 12.1 bug, because I noticed other apps like FB Messenger with this behavior, but I was wondering, is there some kind of workaround for it?


I guess it's Apple's bug But you can try this as a hot fix: just create a class for your tabBar with following code:

import UIKit  class FixedTabBar: UITabBar {      var itemFrames = [CGRect]()     var tabBarItems = [UIView]()       override func layoutSubviews() {         super.layoutSubviews()          if itemFrames.isEmpty, let UITabBarButtonClass = NSClassFromString("UITabBarButton") as? NSObject.Type {             tabBarItems = subviews.filter({$0.isKind(of: UITabBarButtonClass)})             tabBarItems.forEach({itemFrames.append($0.frame)})         }          if !itemFrames.isEmpty, !tabBarItems.isEmpty, itemFrames.count == items?.count {             tabBarItems.enumerated().forEach({$0.element.frame = itemFrames[$0.offset]})         }     } } 


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: