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:
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?
In your UITabBarController
, set isTranslucent = false
Apple has now fixed that in iOS 12.1.1
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]})
}
}
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With