这段代码可以使tabbar的背景改成自己想要的颜色
其实就是在上面加了一层View
UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(self.tabBar.bounds.origin.x, self.tabBar.bounds.origin.y, self.tabBar.bounds.size.width, self.tabBar.bounds.size.height)];
bgView.backgroundColor = [UIColor blackColor];
[self.tabBar insertSubview:bgView atIndex:0];
self.tabBar.opaque = YES;
接下来是去掉顶部的阴影,通过查看可以发现它是一个uiimageview
//去除顶部的分割线
[[UITabBar appearance] setShadowImage:[UIImage new]];
[[UITabBar appearance] setBackgroundImage:[[UIImage alloc]init]];
自定义tabbar的字体颜色
NSMutableDictionary *textattri=[NSMutableDictionary dictionary];
textattri[NSForegroundColorAttributeName]=SLColor(255, 255, 255);
NSMutableDictionary *selecttextattri=[NSMutableDictionary dictionary];
selecttextattri[NSForegroundColorAttributeName]=SLColor(243, 54, 23);
[childVc.tabBarItem setTitleTextAttributes:textattri forState:UIControlStateNormal];
[childVc.tabBarItem setTitleTextAttributes:selecttextattri forState:UIControlStateSelected];
接下来是修改statusbar和navigation的颜色
修改navigation
+(void)initialize
{
//创建NavigationBar,也就是整个上方的视图
UINavigationBar *bar=[UINavigationBar appearance];
//设置NavigationBar的背景
[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
[bar setBarTintColor:[UIColor blackColor]];
UIColor * cc = [UIColor whiteColor];
NSDictionary * dict = [NSDictionary dictionaryWithObject:cc forKey:UITextAttributeTextColor];
bar.titleTextAttributes = dict;
}
status
在。plist文件中加入这两条