
Мое приложение отображает элементы панели вкладок равномерно в версиях iOS ниже 18, что это нормально. Однако в iOS 18 бывают случаи, когда они отображаются как изображения. Как я могу это решить? Я использую стандартный UITabBarController от Apple и не настроил содержимое элементов панели вкладок.
Правильное отображение элементов панели вкладок в iOS 18.
init(title: String = "", image: String = "", sysImaged: Bool = true, rootViewController: UIViewController) {
super.init(rootViewController: rootViewController)
self.title = title
if sysImaged {
self.tabBarItem.image = UIImage(systemName: image)?.withRenderingMode(.alwaysTemplate)
self.tabBarItem.selectedImage = UIImage(systemName: "\(image).fill")?.withRenderingMode(.alwaysTemplate)
} else {
self.tabBarItem.image = UIImage(named: image)?.withRenderingMode(.alwaysTemplate)
self.tabBarItem.selectedImage = UIImage(named: "\(image)_sel")?.withRenderingMode(.alwaysTemplate)
}
self.tabBarItem.imageInsets = UIEdgeInsets(top: 2, left: 2, bottom: 2, right: 2)
self.navigationBar.barStyle = .black
self.modalPresentationStyle = .fullScreen
self.navigationBar.barStyle = UIBarStyle.black
self.navigationBar.tintColor = UIColor.white
self.delegate = self
// https://stackoverflow.com/questions/691 ... ransparent
// 导航栏滚动透明问题
if #available(iOS 15, *) {
UINavigationBar.appearance().scrollEdgeAppearance = UINavigationBarAppearance()
}
}
func configureTabbar() {
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font: UIFont.systemFont(ofSize: 12)], for: .normal)
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font: UIFont.systemFont(ofSize: 12)], for: .selected)
tabBar.barTintColor = UIColor.theme.tabBarBackgroundColor
tabBar.isTranslucent = false
tabBar.tintColor = UIColor.theme.tabbarItemSelectedColor
tabBar.unselectedItemTintColor = UIColor.theme.tabbarItemNormalColor
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... t-in-ios18
Мобильная версия