Positioning UITabBar at the top

前端 未结 9 1658
小鲜肉
小鲜肉 2020-11-28 10:30

I\'m a beginner in iOS development. My question is: is it possible to position UITabBar at the top and how? I can\'t position my UITabBar at the top of the view.

9条回答
  •  有刺的猬
    2020-11-28 11:01

    subviews of TabbarController hide back of Tabbar . so for fix use this code :

    class CustomTabBarController: UITabBarController ,UITabBarControllerDelegate{
    
        override func viewDidLayoutSubviews() {
            tabBar.frame = CGRect(x: 0, y: 0, width: tabBar.frame.size.width, height: tabBar.frame.size.height)
            super.viewDidLayoutSubviews()
            delegate = self
            selectedViewController?.view.frame.origin = CGPoint(x: 0, y: tabBar.frame.size.height)
        }
    
        func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
              selectedViewController?.view.frame.origin = CGPoint(x: 0, y: tabBar.frame.size.height)
        }
    
    }
    

提交回复
热议问题