Can't get a translucent status bar in iOS

2019-02-18 08:51发布

I'm trying to get the standard black translucent status bar in my iOS (iOS 6) app programmatically with no luck. I tried adding the key/value in my info.plist, as well as adding...

[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleBlackTranslucent];

...to no effect. What else could be causing this?

4条回答
我命由我不由天
2楼-- · 2019-02-18 09:28
  1. Delete that line of code.
  2. Click on the project file in the project navigator.
  3. Select your target.
  4. Go to "Summary" tab.
  5. Select the status bar style from the drop down.
查看更多
手持菜刀,她持情操
3楼-- · 2019-02-18 09:42

Thank you everyone for your input! You can set it in the info.plist, or use

[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleBlackTranslucent];

Turns out it was translucent - there was just nothing underneath. What i was missing was this line in my view controller

self.wantsFullScreenLayout = YES;

and thats it!

查看更多
We Are One
4楼-- · 2019-02-18 09:42

Have a look at my answer to this question.

Basically you can change the statusBar in the project summary. Here you can select Status Bar Style Black Transculent from the drop down menu.

查看更多
Lonely孤独者°
5楼-- · 2019-02-18 09:47

you have got the code right. place it in your app delegate in application did finish launching with an option and it should do the trick. i just built a simple view application and just added your code to the app delegate and added an image to the view to test it and it works. you can see it in screen shot below.

enter image description here

good luck.

查看更多
登录 后发表回答