Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何以编程方式闪屏?_Iphone_Cocoa_Xcode - Fatal编程技术网

Iphone 如何以编程方式闪屏?

Iphone 如何以编程方式闪屏?,iphone,cocoa,xcode,Iphone,Cocoa,Xcode,经过长时间的寻找,我不得不放弃并提出要求 是否可以闪烁屏幕(就像使用主页按钮+电源按钮拍摄屏幕截图一样) 如果是的话,怎么办 提前感谢您的回答。将白色全屏UIView添加到窗口中,并设置其alpha动画(播放持续时间和动画曲线以获得所需的结果): 编辑:不要忘记在动画结束后删除该视图类似于Max提供的答案,但使用UIView animateWithDuration - (void)flashScreen { // Make a white view for the flash UIView *w

经过长时间的寻找,我不得不放弃并提出要求

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

如果是的话,怎么办


提前感谢您的回答。

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


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

类似于Max提供的答案,但使用UIView animateWithDuration

- (void)flashScreen {
// Make a white view for the flash
UIView *whiteView = [[UIView alloc] initWithFrame:self.view.frame];
whiteView.backgroundColor = [UIColor whiteColor];
whiteView.alpha = 1.0; // Optional, default is 1.0

// Add the view
[self.view addSubview:whiteView];

// Animate the flash
[UIView animateWithDuration:1.0
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseOut // Seems to give a good effect. Other options exist
                 animations:^{
                     // Animate alpha
                     whiteView.alpha = 0.0;
                 } 
                 completion:^(BOOL finished) {
                     // Remove the view when the animation is done
                     [whiteView removeFromSuperview];
                 }];
}
有不同版本的animateWithDuration,例如,如果您不需要延迟并且可以使用默认动画选项,您也可以使用此较短版本

[UIView animateWithDuration:1.0
                 animations:^{
                     // Animate alpha
                     whiteView.alpha = 0.0;
                 } 
                 completion:^(BOOL finished) {
                     // Remove the view when the animation is done
                     [whiteView removeFromSuperview];
                 }];

这是一个惊人的快速和正确的答案。非常感谢Max!!
[UIView animateWithDuration:1.0
                 animations:^{
                     // Animate alpha
                     whiteView.alpha = 0.0;
                 } 
                 completion:^(BOOL finished) {
                     // Remove the view when the animation is done
                     [whiteView removeFromSuperview];
                 }];