首页 > 移动平台 > 详细

iOS TabbarController 设置底部Toolbar图片和文字颜色选中样式

时间:2016-09-01 18:42:54      阅读:684      评论:0      收藏:0      [点我收藏+]

提取公共方法:

-(void)createChildVcWithVc:(UIViewController *)vc Title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage
{
    
    //图片渲染
    vc.tabBarItem.title=title;
    vc.navigationItem.title=title;
    vc.tabBarItem.image=[UIImage imageNamed:image];
    vc.tabBarItem.selectedImage=[[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    //文字渲染
    NSMutableDictionary *dict=[NSMutableDictionary dictionary];
    dict[NSForegroundColorAttributeName]=[UIColor blackColor];
    [vc.tabBarItem setTitleTextAttributes:dict forState:UIControlStateNormal];
    
    //选中的文字渲染
    dict[NSForegroundColorAttributeName]=[UIColor orangeColor];
    [vc.tabBarItem setTitleTextAttributes:dict forState:UIControlStateSelected];
    
    YJNavigationController *nav=[[YJNavigationController alloc] initWithRootViewController:vc];
    [self addChildViewController:nav];
}

  

 

使用方法:

 YJMeViewController *me=[[YJMeViewController alloc] init];
    [self createChildVcWithVc:me Title:@"我" image:@"tabbar_profile" selectedImage:@"tabbar_profile_selected"];

  

iOS TabbarController 设置底部Toolbar图片和文字颜色选中样式

原文:http://www.cnblogs.com/yajunLi/p/5830696.html

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!