An abstract class that defines the interface for subclassers to interact with the screen saver infrastructure.


class ScreenSaverView : NSView


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.

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().


Initializing a ScreenSaverView

init?(frame: NSRect, isPreview: Bool)

Initializes a newly allocated ScreenSaverView with frame as its frame rectangle, and sets the value returned by isPreview to isPreview.

Getting the preferred window behavior

class func backingStoreType() -> NSWindow.BackingStoreType

Returns the desired backing store for windows in which the screen saver view will be instantiated.

class func performGammaFade() -> Bool

Indicates whether the screen saver application should perform a gradual screen fade when it starts and stops the animation.

Setting and getting the animation time interval

var animationTimeInterval: TimeInterval

Sets the time interval between animation frames.

Animating the ScreenSaverView

func startAnimation()

Activates the periodic timer that animates the screen saver.

func animateOneFrame()

Advances the screen saver’s animation by a single frame.

func stopAnimation()

Deactivates the timer that advances the animation.

var isAnimating: Bool

A Boolean value that indicates if the screen saver is currently animating.

Drawing the ScreenSaverView

func draw(NSRect)

Draws the screen saver view.

var isPreview: Bool

A Boolean value that indicates if the screen saver view was created in a size appropriate for use as a preview.

Accessing the configuration sheet

var hasConfigureSheet: Bool

Returns whether the screen saver has an associated configuration sheet.

var configureSheet: NSWindow?

Returns the window containing all of the controls to be used for configuring the screen saver.