Positioning UITabBar at the top

前端 未结 9 1774
小鲜肉
小鲜肉 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:11

    Swift 5

    Add this code to your UITabBarViewController;

      override func viewDidLayoutSubviews() {
        let height = navigationController?.navigationBar.frame.maxY
        tabBar.frame = CGRect(x: 0, y: height ?? 0, width: tabBar.frame.size.width, height: tabBar.frame.size.height)
        super.viewDidLayoutSubviews()
      }
    

    It works for iOS > 13 and iOS < 13

提交回复
热议问题