簡體   English   中英

我們如何在IOS的屏幕頂部放置標簽欄

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

我通常將標簽欄放在通常的底部,為此我在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;

我找到了一個將其放在頂部的來源,但我想找出更好的方法。 我從以下git項目獲得了一些有關如何放在頂部的知識。 如果有人知道更好的方法,那么我將很高興知道該https://github.com/hollance/MHTabBarController

如何在iPhone的屏幕頂部放置標簽欄

您不能將TabBar移到頂部。 您必須創建自定義的一個。 查看有關自定義標簽欄的文章:

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

在此基礎上,您可以將自定義標簽欄移到頂部並獲得所需的結果

一種方法是,您可以添加UIViewController而不是UITabBarController並在頂部的該視圖控制器中添加tabBar。

此鏈接可能會對您有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM