【问题标题】:IOS: How to change the position of UITabbar to the top of viewIOS:如何将UITabbar的位置更改为视图顶部
【发布时间】:2015-09-30 05:32:04
【问题描述】:

我在我的项目中使用UITAbBar 我想将其位置从视图的底部更改为顶部。 我必须为此输入什么代码。

{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.view.backgroundColor = [UIColor whiteColor];
   self.title = @"Welcome";


    _friendviewcontroller = [FriendsViewController new];
    _homeviewcontroller = [HomePageViewController new];
    _notifviewcontroller = [NotificationViewController new];
    _messageviewcontroller = [MessagesViewController new];

    self.tabbarcontroller = [[UITabBarController alloc]init];

    self.viewControllers = [NSArray arrayWithObjects:_homeviewcontroller,_messageviewcontroller,_friendviewcontroller,_notifviewcontroller, nil];

    //UITabBar *tabBar = self.tabBarController.tabBar;
    UITabBarItem *item0 = [self.tabBar.items objectAtIndex:0];
    UITabBarItem *item1 = [self.tabBar.items objectAtIndex:1];
    UITabBarItem *item2 = [self.tabBar.items objectAtIndex:2];
    UITabBarItem *item3 = [self.tabBar.items objectAtIndex:3];
}

【问题讨论】:

  • 创建 UITabbarController 的子类,并为您提供所需的位置,即使您可以自定义每个按钮的大小和样式。
  • 你可以这样做,我找到了这个link

标签: ios iphone uitabbar


【解决方案1】:
UITabBarController *tabBarController;
tabBarController = [[UITabBarController alloc]init];

// define a custom frame size for the entire tab bar controller that will be in the
// top of the screen.
CGRect tabBarFrame;
tabBarFrame = CGRectMake(0, 0, 320, 200);
tabBarController.view.frame = tabBarFrame;

【讨论】:

    【解决方案2】:

    使用 UITabBarController 是不可能的。它总是停留在底部。

    【讨论】:

      猜你喜欢
      • 2023-03-30
      • 1970-01-01
      • 2021-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-28
      • 1970-01-01
      • 2021-02-05
      相关资源
      最近更新 更多