项目中 -- 设置tabBar样式 (旅游局)

- (void)addChildViewController:(UIViewController *)ViewController image:(UIImage *)image selectImg:(UIImage *)selectImg title:(NSString *)title navTitle:(NSString *)navTitle{

    // 设置navigationBarItem 和 tabBarItem

    ViewController.title = title;

   // 关键代码 将系统的tabBar的title上调

    [ViewController.tabBarItem setTitlePositionAdjustment:UIOffsetMake(0, -3)];

    ViewController.tabBarItem.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    ViewController.tabBarItem.selectedImage = [selectImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    // 设置tabBarItem title样式

    [ViewController.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor grayColor]} forState:UIControlStateNormal];

    [ViewController.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor redColor]} forState:UIControlStateSelected];

    // 添加导航栏

    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:ViewController];

    ViewController.navigationItem.title = navTitle;

 

    [self addChildViewController:navigation];

}

 

posted @ 2017-01-02 22:00  二十几岁的某一天  阅读(173)  评论(0)    收藏  举报