如何以编程方式闪屏?

Pat*_*ryk 4 iphone xcode cocoa

经过长时间的搜索,我不得不放弃并问.

是否可以闪屏(就像使用主页按钮+电源按钮拍摄屏幕截图一样)?

如果是,那怎么样?

提前感谢您的回答.

Max*_*Max 6

将白色全屏UIView添加到窗口并为其动画显示为alpha(使用持续时间和动画曲线播放以获得所需的结果):

 -(void) flashScreen {
    UIWindow* wnd = [UIApplication sharedApplication].keyWindow;
    UIView* v = [[[UIView alloc] initWithFrame: CGRectMake(0, 0, wnd.frame.size.width, wnd.frame.size.height)] autorelease];
    [wnd addSubview: v];
    v.backgroundColor = [UIColor whiteColor];
    [UIView beginAnimations: nil context: nil];
    [UIView setAnimationDuration: 1.0];
    v.alpha = 0.0f;
    [UIView commitAnimations];
}
Run Code Online (Sandbox Code Playgroud)

编辑:动画结束后不要忘记删除该视图