@kienw notice how the tab bar usually displays the tab bar item image + title horizontally in a regular size class, but vertically when compact and it might be nice to adjust this too. This lead me to adjusting it all within the custom tab bar controller
class CustomTabBarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
if #available(iOS 18.0, *), UIDevice.current.userInterfaceIdiom == .pad {
traitOverrides.horizontalSizeClass = .compact
}
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
if #available(iOS 18.0, *), UIDevice.current.userInterfaceIdiom == .pad {
tabBar.traitOverrides.horizontalSizeClass = rootViewControllerHorizontalSizeClass
viewControllers?.forEach { viewController in
viewController.adjustSizeClass()
}
}
}
}
From my brief testing this has been fine and might be a backup solution while figuring out how to work with the new design.
Another option if the trait overrides feels too much like a hack. might be to do a custom tab bar controller and using a UITabBar directly. Alternatively hiding the default one as @DTS Engineer says and adding your own to manage.
Topic:
UI Frameworks
SubTopic:
General
Tags: