简体   繁体   English

我们如何在IOS的屏幕顶部放置标签栏

[英]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. 我通常将标签栏放在通常的底部,为此我在application didFinishLaunchingWithOptions使用了以下代码。

    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. 我从以下git项目获得了一些有关如何放在顶部的知识。 If any one knows some better way then i will be glad to know about that https://github.com/hollance/MHTabBarController 如果有人知道更好的方法,那么我将很高兴知道该https://github.com/hollance/MHTabBarController

How to place tab bar on top of screen in iPhone 如何在iPhone的屏幕顶部放置标签栏

You cannot move the TabBar to the top. 您不能将TabBar移到顶部。 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/ 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 在此基础上,您可以将自定义标签栏移到顶部并获得所需的结果

One way is, you can add UIViewController instead of UITabBarController and add a tabBar to that view controller on the top. 一种方法是,您可以添加UIViewController而不是UITabBarController并在顶部的该视图控制器中添加tabBar。

This link may help you. 此链接可能会对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM