我已经设法确保iPhone不会自动锁定:
- [[ UIApplication sharedApplication ] setIdleTimerDisabled: YES ];
但是如何在一段时间后使屏幕变暗?
谢谢…
编辑:
认为我自己找到了一个解决方案:
通过添加50%alpha的黑色视图,在视图控制器中使用此方法.确保将userInteractionEnabled = NO设置为将事件传递给底层视图.
- - (IBAction)dim:(id)sender {
- UIView *dimView = [[UIView alloc] initWithFrame:CGRectMake(0,320,460)];
- dimView.backgroundColor = [UIColor blackColor];
- dimView.alpha = 0.5f;
- dimView.userInteractionEnabled = NO;
- [self.view addSubview:dimView];
- }
或者可能冒险(但苹果可能拒绝提交):
- [(id)[UIApplication sharedApplication] setBacklightLevel:1.0f];
这是一个私有API,不应该被使用…