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

提取公共方法:

-(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"];

  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值