-
(void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
CGRect frame = self.tabBar.frame;
frame.size.height = 55;
frame.origin.y = self.view.frame.size.height - frame.size.height;
self.tabBar.frame = frame;
self.tabBar.backgroundColor = mRGBToColor(0xeaeaea);
self.tabBar.barStyle = UIBarStyleBlack;
//此处需要设置barStyle,否则颜色会分成上下两层
}
修改 导航条 填充色 :
-
[self.tabBar setBarTintColor:ZRMainColor];
-
UIView *view = [[UIView alloc]init];
view.backgroundColor = [UIColor redColor];
view.frame = self.tabBar.bounds;
[[UITabBar appearance] insertSubview:view atIndex:0]; -
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"tabBarBackgroundImage"]];
// [UITabBar appearance].translucent = NO;
导航条 透明,顶端线也透明:
[self.tabBar setShadowImage:img];
[self.tabBar setBackgroundImage:[[UIImage alloc]init]];
appearanceWhenContainedInInstancesOfClasses 与 appearance 区别,前者 设置几个类 的TabBar 属性 后者 统一设置
image.png image.png
网友评论