如题
ios8.2
用一个navigationController包住一个tableViewController
然后设置了navbar背景
- (void)viewDidLoad {
[super viewDidLoad];
//navbar背景
UINavigationBar *navBar = [UINavigationBar appearance];
[navBar setBackgroundColor:MCOLOR(COLOR_GLOBAL_B2)];
//去除边框
[self.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[self.navigationBar setShadowImage:[[UIImage alloc] init]];
//title样式
[self.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:20], NSFontAttributeName, MCOLOR(@"gray"), NSForegroundColorAttributeName, nil]];
}
显示的效果如下
求解决!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
原因出在你设置了 [navBar setBackgroundColor:MCOLOR(COLOR_GLOBAL_B2)];
不要设置navigationBar的背景色就好了。
但是你这样效果就会全透明,你的UIImage没有赋值图片,navigationbar就会全透明,
建议应该最好是半透明的毛玻璃效果最好,很多应用都是这种效果。