Contents

setDesktopImageURL(_:for:options:)

Sets the desktop image for the given screen to the image at the specified URL.

Declaration

func setDesktopImageURL(_ url: URL, for screen: NSScreen, options: [NSWorkspace.DesktopImageOptionKey : Any] = [:]) throws

Parameters

  • url:

    A file URL to the image. The URL must not be nil.

  • screen:

    The screen on which to set the desktop image.

  • options:

    The options dictionary may contain any of the keys in Desktopimageoptionkey, which control how the image is scaled on the screen.

Discussion

Instead of presenting a user interface for picking the options, choose appropriate defaults and allow the user to adjust them in the System Preference Pane.

You must call this method from your app’s main thread.

See Also

Managing the Desktop Image