Nischal Hada
Nischal Hada

Reputation: 3288

How can we place tab bar on top of screen in IOS

I have usually placed tab bar on its as usual bottom I have used following code in application didFinishLaunchingWithOptions for that.

    MemberVC *MemberTabBar = [[MemberVC alloc]init];
    UINavigationController *navMember =   [[UINavigationController alloc] initWithRootViewController:MemberTabBar];
    MemberTabBar.tabBarItem.title = @"Member";

    MemberTabBar.tabBarItem.image = [[UIImage imageNamed:@"home_icon.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    MemberTabBar.tabBarItem.selectedImage = [[UIImage imageNamed:@"home_icon.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    -----------------------
    self.tabBarController = [[UITabBarController alloc]init];
      self.tabBarController.viewControllers = @[navMember,navEvent,navPromo,navProfile,navAbout];
    self.window.rootViewController = tabBarController;
    tabBarController.selectedIndex = 0;

I haver found one source to place it in top but i want to find out the better way. I have gained some knowledge about how to place in top from following git projects. If any one knows some better way then i will be glad to know about that https://github.com/hollance/MHTabBarController

How to place tab bar on top of screen in iPhone

Upvotes: 0

Views: 2901

Answers (2)

PAn Kaj Khatri
PAn Kaj Khatri

Reputation: 539

You cannot move the TabBar to the top. You'll have to create custom one. Check this article about customizing tab bar:

http://idevrecipes.com/2011/01/04/how-does-the-twitter-iphone-app-implement-a-custom-tab-bar/

Basing on it you may move the custom tab bar to the top and acheive desired result

Upvotes: 1

i 4322946
i 4322946

Reputation: 173

One way is, you can add UIViewController instead of UITabBarController and add a tabBar to that view controller on the top.

This link may help you.

Upvotes: 0

Related Questions