首先在屏幕覆盖一层View, 将其透明度设置成透明
self.redView =[[UIView alloc] initWithFrame:kMainScreenFrame];
self.redView.backgroundColor = KcolorRed;
[kMainWindow addSubview:self.redView];
[self.redView setAlpha:0];
闪烁事件如下, 根据自己需要添加在何处
//屏幕红光闪烁
- (void)screenFlicker {
//定时器的添加为了屏幕一直闪烁
if (self.twinkleTime) {
[self.twinkleTime invalidate];
self.twinkleTime = nil;
}
self.twinkleTime = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(screenFlicker) userInfo:nil repeats:YES];
[self.redView setAlpha:1];
[UIView beginAnimations:@"flash screen" context:nil];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[self.redView setAlpha:0.0f];
[UIView commitAnimations];
}