您的位置:首页 > Web前端 > CSS

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

2016-09-01 17:31 645 查看
提取公共方法:

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


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐