Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITabBar items jumping on back navigation on iOS 12.1

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:

enter image description here

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?

like image 585
Igor Kulman Avatar asked Oct 31 '18 13:10

Igor Kulman


4 Answers

In your UITabBarController, set isTranslucent = false

like image 147
binhnguyen14 Avatar answered Nov 17 '22 08:11

binhnguyen14


Apple has now fixed that in iOS 12.1.1

like image 25
Valerio Avatar answered Nov 17 '22 08:11

Valerio


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]})
        }
    }
}
like image 5
Egor Avatar answered Nov 17 '22 09:11

Egor


In my case (iOS 12.1.4), I found that this weird glitchy behaviour was triggered by modals being presented with the .modalPresentationStyle = .fullScreen

After updating their presentationStyle to .overFullScreen, the glitch went away.

like image 4
Edouard Barbier Avatar answered Nov 17 '22 09:11

Edouard Barbier