修改NavigationController中present出来的个别ViewController状态栏颜色

2016年11月29日 iOS 3条评论 阅读6061次


修改NavigationController中present出来的个别ViewController状态栏颜色


对于整体都是push方式展示ViewController的应用,一般来说状态栏都是白色字体,但偶尔还会有presentViewController的情况,此时present出来的ViewController的背景默认是白色的,这样就导致状态栏上的运营商、信号、时间、电量等信息看不清了。

下面是针对个别present出来的ViewController临时修改状态栏颜色风格的代码。

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    // 这个页面被加载之后,状态栏设置为黑色
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
}


- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    // 页面即将消失时,状态栏再转为白色
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
}


参考了jianshu上的一篇文章,抱歉地址没有记下来,那篇文章是swift实现的,并且状态栏设置为黑色的代码是放在viewDidLoad中,经过我的实验测试证明,viewDidLoad中去修改状态栏为黑色会在页面再次跳转到某一页面返回后重新变得状态栏为白色。


分享本文至:

WRITTEN BY

avatar
本文标签:NavigationController
看了本文是不是觉得很赞,那就赶紧点击下面按钮分享给身边的朋友吧!

3 条评论

  1. avatar foliekopen

    <a href="http://www.bhcsboosters.com/bon-march%C3%A9-nike-shox-r4-femmes-runningf">bon march茅 nike shox r4 femmes</a> <a href="http://www.denisgoulart.com/35-authentic-grant-hill-detroit-pistons-jersey-mens-adidas-nba-purple-throwback-1995-all-nflv">35 authentic grant hill detroit pistons jersey mens adidas nba purple throwback 1995 all</a> <a href="http://www.donggeomdo.com/lebron-12-yellow-and-red-makeup-trainersa">lebron 12 yellow and red makeup</a> <a href="http://www.ozoessaouira.com/salomon-s-lab-xt-6-softground-negro-man-shot-scarpec">salomon s lab xt 6 softground negro man shot</a> <a href="http://www.annomaplexel.com/le-coq-sportif-dam%C3%A4nner-schuhe-rosa-gr%C3%BCn-kurpesc">le coq sportif dam盲nner schuhe rosa gr眉n</a> <a href="http://www.bringribben.com/ray-ban-aviator-1937-price-bangalore-sunglassesg">ray ban aviator 1937 price bangalore</a>
    foliekopen http://www.foliekopen.com/

  2. avatar godskingdoms

    <a href="http://www.akncmusic.com/air-jordan-retro-14-himmelen-bl%C3%A5-gamma-bl%C3%A5-schuheb">air jordan retro 14 himmelen bl氓 gamma bl氓</a> <a href="http://www.dystopianflix.com/adidas-climacool-ride-iv-herren-wei%C3%9F-chaussuresd">adidas climacool ride iv herren wei脽</a> <a href="http://www.getunladylike.com/kvinners-nike-flynit-air-max-bl%C3%A5-r%C3%B8d-butyf">kvinners nike flynit air max bl氓 r酶d</a> <a href="http://www.jesselyon.com/nike-kobe-12-bl%C3%A5-himmelbl%C3%A5-scarpea">nike kobe 12 bl氓 himmelbl氓</a> <a href="http://www.kabukcuoglu.com/air-jordan-4-retro-rot-python-schuheb">air jordan 4 retro rot python</a> <a href="http://www.karbasioun.com/air-jordan-super-fly-brun-guld-butye">air jordan super fly brun guld</a>
    [url=http://www.godskingdoms.com/]godskingdoms[/url]

  3. avatar mobilekosar

    <a href="http://www.troyafolklor.com/ray-ban-wayfarer-blue-tortoise-shell-sunglassesr">ray ban wayfarer blue tortoise shell</a> <a href="http://www.euniscpa.com/mulberry-clipper-mole-cognac-scotchgrain-mulberryd">mulberry clipper mole cognac scotchgrain</a> <a href="http://www.justwhatilove.com/nike-air-max-90-sneakerboot-dam%C3%A4nner-wei%C3%9F-sneakerd">nike air max 90 sneakerboot dam盲nner wei脽</a> <a href="http://www.kevise.com/parajumpers-vest-quick-baked-parajumpersb">parajumpers vest quick baked</a> <a href="http://www.incaradio.com/how-to-use-burberry-scarf-scarfr">how to use burberry scarf</a> <a href="http://www.qubellinfo.com/hermes-evelyne-gm-size-hermesr">hermes evelyne gm size</a>
    mobilekosar http://www.mobilekosar.com/

欢迎留言




用户登录

sitemap