uinavigationcontroller - ios statusbar背景透明能看到下层view的数据
迷茫
迷茫 2017-04-17 14:37:44
[iOS讨论组]

如题
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]];
}

显示的效果如下

求解决!

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

全部回复(2)
ringa_lee
- (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]];

    //添加这一行
    [self.navigationBar setBarTintColor:MCOLOR(COLOR_GLOBAL_B2)];
}

PHP中文网

原因出在你设置了 [navBar setBackgroundColor:MCOLOR(COLOR_GLOBAL_B2)];
不要设置navigationBar的背景色就好了。
但是你这样效果就会全透明,你的UIImage没有赋值图片,navigationbar就会全透明,

建议应该最好是半透明的毛玻璃效果最好,很多应用都是这种效果。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号