添加tabbarControler的子控制器的一些基本设置

/**
 *  添加tabbarControler的子控制器
 */
- (void)addChildViewController:(UIViewController *)childCtrl imageName:(NSString *)imageName title:(NSString *)title
{
    
    //设置选中与未选中的图片-->指定一下渲染模式-->图片以原样的方式显示出来
    childCtrl.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    childCtrl.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",imageName]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    //设置标题
    //    childCtrl.tabBarItem.title = title;
    //    childCtrl.navigationItem.title = title;
    childCtrl.title = title;
    
    //    childCtrl.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
    //指定一下属性
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    dic[NSForegroundColorAttributeName] = [UIColor orangeColor];
    //指定字体
    //    dic[NSFontAttributeName] = [UIFont systemFontOfSize:16];
    
    //指定选中状态下文字颜色
    [childCtrl.tabBarItem setTitleTextAttributes:dic forState:UIControlStateSelected];
    
    //    SDNavigationController *nav = [[SDNavigationController alloc]initWithRootViewController:childCtrl];
    
    [self addChildViewController:childCtrl];
}


你可能感兴趣的:(添加tabbarControler的子控制器的一些基本设置)