Status bar color changed when change UINavigationBar appearance backgroundimage

喜你入骨 提交于 2019-12-13 13:13:24

问题


I use this line of code to change navigation bar background:

    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"image.png"] forBarMetrics:UIBarMetricsDefault];

in iOS6, it works, but in iOS5, background of the status bar is changed too, as shown in this image:

how does this happen. Thanks in advance.

One more thing, I just want to change the color of UINavigationBar, so I used this code:

[[UINavigationBar appearance] setTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]]];

It works in iOS6 quite well, but does not in iOS5. What is the reason?


回答1:


You can use this one to set your status bar

 [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];

So status bar colour will be black and font colour will be white..



来源:https://stackoverflow.com/questions/13722173/status-bar-color-changed-when-change-uinavigationbar-appearance-backgroundimage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!