I suggest using the CGDisplayFade API of Quartz Display Services.
It's very easy to use and no "hacking" with fake fullscreen windows or views is required.
See here: Quartz Display Services Reference
A simple implementation would look like this:
-(void)flashScreenUsingFlashColor:(NSColor *)flashColor
inDuration:(NSTimeInterval)inDuration
outDuration:(NSTimeInterval)outDuration{
CGDisplayFadeReservationToken fadeToken;
NSColor *colorToUse = [flashColor colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
CGError error = CGAcquireDisplayFadeReservation (inDuration + outDuration, &fadeToken);
if (error != kCGErrorSuccess){
NSLog(@"Error aquiring fade reservation. Will do nothing.");
return;
}
CGDisplayFade (fadeToken, inDuration, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, colorToUse.redComponent, colorToUse.greenComponent, colorToUse.blueComponent, true);
CGDisplayFade (fadeToken, outDuration, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal,colorToUse.redComponent, colorToUse.greenComponent, colorToUse.blueComponent, false);
}
.notImplemented
– Pazice