IOS:如何将UITabbar的位置更改为视图顶部

时间:2015-09-30 05:32:05

标签: ios iphone uitabbar

我在我的项目中使用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];
}

2 个答案:

答案 0 :(得分: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;

答案 1 :(得分:-1)

UITabBarController无法实现。它始终保持在最低点。