Search code examples
swiftmacosanimationscreenshotnsview

How to obtain a screen flash effect like screen capture effect?


Is there any way to obtain a flash screen effect like the one produced when a screenshot is taken, on demand, for a certain NSView? My question is not a duplicate of flashing screen programatically with Swift (on 'screenshot taken') , since I need a solution for osx, not ios and the methods are different.


Solution

  • The way to achieve this is to create a new UIView that is the same size of the screen, and black in color, add it a subview of your view then animate the alpha to zero( play around with the duration to achieve the desired effect) after completion remove the view from superview.

    I have used this technique in many of my projects and it works like a charm. You can play around with the background color of the view to customize the look of the flash.