Reputation: 941
I am looking for a way to turn off the iPhone screen without the iPhone going to sleep. I don't really mind if turning the screen off is against apple rules. Would setting window alpha to 0 do the trick? Is there maybe some sort of boolean value I can change?
If anyone has an ideas they would be much appreciated.
Many thanks,
Stu
Upvotes: 2
Views: 2092
Reputation: 32803
First make the statusbar invisible:
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
Then create a subview with the backgroundColor to black:
CGRect rect = [[UIScreen mainScreen] applicationFrame];
UIView *bg = [[UIView alloc] initWithFrame:rect];
bg.backgroundColor = [UIColor blackColor];
[window addSubview:bg];
The reason for making the statusbar hidden first, is so that the [[UIScreen mainScreen] applicationFrame]
call will cover the whole screen.
Upvotes: 3