I have a Tab Bar Controller which, as we know, displays the tab bar at the bottom of the screen. I'm looking for a way to move it to the top. I don't think I can use a simple UITabBar
for this as I need to nest UINavigationControllers
under it.
Is there any way to move the Tab Bar in a UITabBarController
to the top of the screen?
(in Swift)
In the TabBarViewController.swift file (everyone has named this file as he wants):
First: create an IBOutlet of a tab bar and then connect it to the appropiate tab bar in the storyboard or in the nib file.
Second: add this code in the viewDidLoad() function to situate the tab bar where you want (in this case I add de tab bar under the navigation controller). To modify the position change x and y of CGRectMake initializer.
Try this code in methods "viewDidLayoutSubviews" your UITabBarController
Swift 2.X
Swift 3.X
Swift 4.X
I use
Tab Bar Controller
then I simply change theTabBar
position in theTab Bar Controller
in theViewDidLoad()
Here is the Screen Short attached of the required result... Tab bar on top in tab bar view conmtroller
Note: It is in swift 3 you can change the syntax to swift 2.* on your own.
I dont think so. The only thing I can think of is to use UITabBar instead of UITabbarController ...
This might be a better option anyway if you are considering nesting UINavigationControllers for each view loaded for the different tabs.