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];
}];