ScreenSaverView is an abstract class that defines the interface for subclassers to interact with the screen saver infrastructure.
Language
- Swift
- Objective-C
SDK
- macOS 10.10+
Overview
Screen savers are subclasses of ScreenSaverView, packaged up in bundles and loaded by the screen saver application. (These bundles have a suffix of .saver and are located in the Library/Screen Savers directories of the various file system domains. See File System Overview for information about domains.) ScreenSaverView defines an interface for animating screen savers, instantiating small preview versions of the screen saver view (for display in System Preferences, for example), and for providing a configuration sheet to set various properties of the screen saver. In addition, subclasses can set the animation interval, the backing store of their window, and how the screen transitions to the animation.
Note
When a user clicks Preview in Screen Saver System Preferences, your ScreenSaverView subclass is instantiated.
There are two main ways to do drawing in a screen saver. You can either do your drawing in the NSView method draw(_:), or you can do your drawing in the ScreenSaverView method animateOneFrame(). If you do drawing in draw(_:), you should call setNeedsDisplay: with an argument of true in animateOneFrame().