OC-UITabBar上相关设置

  • 去掉黑线
[UITabBar appearance].barStyle = UIBarStyleBlack;
  • 自定义黑线颜色
CGRect rect = CGRectMake(0, 0, [UIApplication sharedApplication].keyWindow.bounds.size.width, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[UITabBar appearance].shadowImage = image;
  • 设置背景色
[UITabBar appearance].backgroundColor = hw_BGColor;
  • 自定义背景图片
[UITabBar appearance].backgroundImage = [UIImage imageNamed:@"TabBar_BG"];
  • 设置字体偏移
[UITabBarItem appearance].titlePositionAdjustment = UIOffsetMake(0.0,0.0);
  • 字体
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} forState:UIControlStateNormal];
  • 未选中颜色
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:self.normalColor} forState:UIControlStateNormal];
  • 选中颜色
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:self.selectColor} forState:UIControlStateSelected];

注意:有点设置无限需要将[UITabBar appearance].translucent = YES;才可以

  • NavigationController 隐藏黑线
self.navigationBar.barStyle = UIBaselineAdjustmentNone;

你可能感兴趣的:(OC-UITabBar上相关设置)