1

I have 2 views in my app: my root view has a button. When you click on that button, you get sent to another view. In that view, I just want to display a completely black screen, as if the iPhone was turned off. What object in the interface builder should I use for this? Sorry if it's a beginner question.

Hot Licks
  • 47,103
  • 17
  • 93
  • 151
bigpotato
  • 26,262
  • 56
  • 178
  • 334
  • 1
    when the iPhone is turned off, its not a black screen. Its actually completely off. Black screen on the other hand, keeps the screen ON. Are you expecting the leds to turn off? or just should a full screen view that is BLACK in color? (former I think, is not possible, latter is) – Nitin Alabur May 18 '14 at 18:42
  • Yea would that be the same as setting the background to black? I want it to look like the phone is off. Yea I want the LEDs to be off – bigpotato May 18 '14 at 18:44
  • no, it won't be the same. I just checked it with using Sketch Mirror. You can see a faint glow when its black colored screen. – Nitin Alabur May 18 '14 at 18:49

2 Answers2

3

I don't think it's possible to turn the LEDs all the way off. You can however make it look like they are by turning the brightness all the way down in code like this:

[[UIScreen mainScreen] setBrightness:0.0];
vegather
  • 470
  • 4
  • 14
  • Where would I put this line in my controller? in `viewDidLoad`? – bigpotato May 26 '14 at 18:24
  • @Edmund You can put it wherever you need it to go. Just did a quick test for the app you described above. Worked fine if I put it in viewDidLoad for the second UIViewController. You can combine it with this line `self.view.backgroundColor = [UIColor blackColor];` to make the screen appear even darker. If you want to reverse that when you go back, just do the opposite in `- (void)viewWillAppear:(BOOL)animated` of the first UIViewController. Set the brightness to 1.0 and the backgroundColor to white. Hope this helps. – vegather May 26 '14 at 18:35
0

If you enable proximity monitoring, then os will turn screen off.

Otherwise, the only way you can turn it off is by accessing undocumented methods (risking app store rejection)

Turn off display in iPhone OS (iOS)

Community
  • 1
  • 1
Nitin Alabur
  • 5,812
  • 1
  • 34
  • 52