How to display a red status bar when the home button is pressed?

Deadly 提交于 2020-05-27 01:54:18

问题


How do I display a red status bar when the home button is pressed while my recoding app is doing some recording?

I checked this question: How to hide the red bar under the iOS's status when recording?

However, I use Core Audio and Extended Audio File Services to do recording. I am unable to find any proper documentation to programatically do this. Any help or pointers will be appreciated.

Red status bar


回答1:


I believe from saying

a red status bar when the home button is pressed

you are asking whether you can set the status bar color to red when your app in background.

The red status bar is an indication that an application is recording audio, and it is set by the system. There is nothing in sdk that supports us to change the status bar color when your application is in the background.

See this official forum thread (login required) where this question is addressed, and the guy who answeres it is an Apple employee.

EDIT :

If your app is trying to record in the background, but your problem is that red color is not visible on status bar, then one reason can be because your audio recording session is getting terminated/paused. Try and register for a completion handler for your recording, and see if it fires earlier than you expects it to fire.




回答2:


This is private, but works

 [[[UIApplication sharedApplication] statusBar] setTintColor:[UIColor redColor] withDuration:3.2]

of course that will get rejected in the store.

Ideally you could just add a category onto UIStatusBar and override drawRect:, which is how I used to tint my nav bars, but it looks like that class is private as well.

There are probably a few runtime hacks that might get you around it, but you'd still running the risk of having your app thrown out later.

Perhaps apple will open this one up later on, as they did with the nav and tab bars?



来源:https://stackoverflow.com/questions/14273824/how-to-display-a-red-status-bar-when-the-home-button-is-pressed

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