Я хочу создать панель вкладок с динамической вкладкой. Я создал панель вкладок с динамическими вкладками, но когда я перехожу к экрану сведений с экрана панели вкладок, в этом контроллере подробностей появляется черное пространство. Пожалуйста, предложите мне правильный способ его реализации. Вот мой код.
func creatTabBarProgrammatically(bottomMenuArray:[Any]) {
DispatchQueue.main.async {
self.navigationController?.setNavigationBarHidden(true, animated: false)
let tabBarController = UITabBarController()
tabBarController.tabBar.backgroundImage = self.getImageWithColor(UIColor.white, size: CGSize(width: self.view.frame.size.width, height: 49))
tabBarController.hidesBottomBarWhenPushed = true
let firstViewController = self.storyboard?.instantiateViewController(withIdentifier: "HomeViewController") as! HomeViewController
let ordersViewController = self.storyboard?.instantiateViewController(withIdentifier: "OrdersViewController") as! OrdersViewController
let myProfileViewController = self.storyboard?.instantiateViewController(withIdentifier: "MyProfileViewController") as! MyProfileViewController
var controllers = [Any]()
controllers.append(firstViewController)
for i in 0 ..< bottomMenuArray.count{
if let dict = bottomMenuArray[i] as? [String:Any]{
if let name = dict["name"] as? String{
if name == "orders"{
controllers.append(ordersViewController)
}
else if name == "profile"{
controllers.append(myProfileViewController)
}else{
}
}
}
}
tabBarController.viewControllers = controllers as? [UIViewController]
// Setting Title selected image and unselected image to tab
for i in 0 ..< bottomMenuArray.count{
if let dict = bottomMenuArray[i] as? [String:Any]{
if let name = dict["name"] as? String{
if name == "orders"{
let tabBarItem :UITabBarItem = tabBarController.tabBar.items![i + 1]
tabBarItem.title = "Orders"
tabBarItem.selectedImage = UIImage(named: "tabordersselected")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
tabBarItem.image = UIImage(named: "tabordersunselected")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
}
else if name == "profile"{
let tabBarItem :UITabBarItem = tabBarController.tabBar.items![i + 1]
tabBarItem.title = "Profile"
tabBarItem.selectedImage = UIImage(named: "tabprofileselected")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
tabBarItem.image = UIImage(named: "tabprofileunselected")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
}else{
}
}
}
}
let tabBarItem1:UITabBarItem = tabBarController.tabBar.items![0]
tabBarItem1.title = "Home"
tabBarItem1.selectedImage = UIImage(named: "tabhomeselected")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
tabBarItem1.image = UIImage(named: "tabhomeunseleted")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
tabBarController.viewControllers = controllers.map { UINavigationController(rootViewController: $0 as! UIViewController)}
self.navigationController!.pushViewController(tabBarController, animated: false)
}
}