<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "ScreenSaver",
  "identifier" : "/documentation/ScreenSaver",
  "metadataVersion" : "0.1.0",
  "role" : "Framework",
  "symbol" : {
    "kind" : "Framework",
    "modules" : [
      "Screen Saver"
    ],
    "preciseIdentifier" : "ScreenSaver"
  },
  "title" : "Screen Saver"
}
-->

# Screen Saver

Animate screen savers, and interact with the screen saver infrastructure.

## Overview

The Screen Saver framework defines the interface for custom modules to interact with the Screen Effects user interface feature. Write screen savers in Objective-C, and implement your module’s user interface using Cocoa. Use the available functions to produce random values and centering rectangles.

To create a screen saver, create a bundle directory with the `.saver` suffix and install it in one of the `Library/Screen Savers` directories on the system. In your bundle’s executable, include a [`ScreenSaverView`](/documentation/ScreenSaver/ScreenSaverView) subclass. That view defines the interface you use to generate your screen saver content. If your screen saver stores any preference information, use the [`ScreenSaverDefaults`](/documentation/ScreenSaver/ScreenSaverDefaults) class instead of the standard <doc://com.apple.documentation/documentation/Foundation/UserDefaults> class.

Because screen savers are plug-ins for the screen saver engine, the screen saver binary must support the same hardware architecture of the running engine. As with any application, the screen saver engine uses the native architecture of the host computer. For full compatibility, make sure your screen saver supports both the `x86_64` and `arm64` architectures.

### How the system runs your screen saver

When macOS starts your screen saver, the system:

1. Fades the screen to black.
2. Instantiates your [`ScreenSaverView`](/documentation/ScreenSaver/ScreenSaverView) subclass and calls its [`init(frame:isPreview:)`](/documentation/ScreenSaver/ScreenSaverView/init(frame:isPreview:)) method.
3. Creates a window and installs your [`ScreenSaverView`](/documentation/ScreenSaver/ScreenSaverView) subclass in it.
4. Activates the window and sets its order.
5. Calls your view’s [`draw(_:)`](/documentation/ScreenSaver/ScreenSaverView/draw(_:)) method so you can draw your initial state.
6. Fades in the screen to reveal your window in the front.
7. Calls your view’s [`startAnimation()`](/documentation/ScreenSaver/ScreenSaverView/startAnimation()) method, which you use to set up any animation-related state information.
8. Calls your view’s [`animateOneFrame()`](/documentation/ScreenSaver/ScreenSaverView/animateOneFrame()) method repeatedly.

When the user takes some action, the system calls your view’s [`stopAnimation()`](/documentation/ScreenSaver/ScreenSaverView/stopAnimation()) method to stop your screen saver. Use that method to clean up any state information you establish in your [`startAnimation()`](/documentation/ScreenSaver/ScreenSaverView/startAnimation()) method.

> Note:
> The ``doc://com.apple.screensaver/documentation/ScreenSaver/ScreenSaverView/stopAnimation()`` or ``doc://com.apple.screensaver/documentation/ScreenSaver/ScreenSaverView/startAnimation()`` methods don’t immediately start or stop the animations. The system can still call your ``doc://com.apple.screensaver/documentation/ScreenSaver/ScreenSaverView/animateOneFrame()`` method after calling ``doc://com.apple.screensaver/documentation/ScreenSaver/ScreenSaverView/stopAnimation()``.

## Topics

### Interface

[`ScreenSaverView`](/documentation/ScreenSaver/ScreenSaverView)

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

[`ScreenSaverDefaults`](/documentation/ScreenSaver/ScreenSaverDefaults)

A class that defines a set of methods for saving and restoring user defaults for screen savers.

### Utilities

[`SSRandomIntBetween`](/documentation/ScreenSaver/SSRandomIntBetween(_:_:))

Returns a random integer value.

[`SSRandomFloatBetween`](/documentation/ScreenSaver/SSRandomFloatBetween(_:_:))

Returns a random float value.

[`SSRandomPointForSizeWithinRect`](/documentation/ScreenSaver/SSRandomPointForSizeWithinRect(_:_:))

Returns a random point.

[`SSCenteredRectInRect`](/documentation/ScreenSaver/SSCenteredRectInRect(_:_:))

Returns a rectangle.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)