0

I am currently stuck at a road block in designing my app in which I need the tab bar in UITabBarController to be moved to the top of the screen.

I understand in app design it doesn't make sense, but I need to be able to put it at the top for it to work.

If there isn't a way to do so, is there possibly a way to do it with the UITabBar item itself. I haven't worked out how to actually use it, as there is not that much documentation nor information about the item itself out there.

Even though my best option is to probably go down the SwiftUI route, I am relatively new to coding and have little to no knowledge and I don't want to have to change all my code in order to work around this one element.

Thanks for understanding.

gnielio
  • 351
  • 1
  • 2
  • 9
  • Here are some ideas: https://stackoverflow.com/questions/29579992/positioning-uitabbar-at-the-top . Another option is using segment control with child view controllers to create your own tab bar. – Shawn Frank Apr 06 '22 at 02:24
  • You can't put the native tab bar to the top of the screen, you have to create your own – Tad Apr 06 '22 at 02:31

1 Answers1

0

Add this code to your Controller

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()
  }
  • where should this be placed? I'm not quite sure how to actually define the tab bar either or class it. – gnielio Apr 06 '22 at 06:42