Class

PHLivePhotoView

A PHLivePhotoView object is a view that displays a Live Photo—a picture that also includes motion and sound from the moments just before and after its capture.

Overview

After obtaining a PHLivePhoto object, use a Live Photo view to display the photo and control playback of its motion and sound content. In iOS and tvOS, you can obtain Live Photo objects from the Photos library, using the UIImagePickerController or PHAsset and PHImageManager classes, or by creating one from asset resources exported from a Photos library. In macOS, Live Photo objects are available only when editing Live Photo content in a photo editing extension that runs in the Photos app—see the PHContentEditingInput class to access Live Photo content in an editing session.

By default, a Live Photo view uses its own gesture recognizer to allow the user to play the motion and sound content of a Live Photo with the same interactions and visual effects seen in the Photos app. To customize this gesture recognizer—for example, to install it on a different view for proper event handling in your app’s view hierarchy—use the playbackGestureRecognizer property.

Typically, an app does not need to directly control Live Photo playback. In some situations, however, it can be useful to briefly animate the view to indicate to the user that a picture is a Live Photo. To do this, use the startPlayback(with:) method with the hint option.

Topics

Choosing a Live Photo to Display

var livePhoto: PHLivePhoto?

The Live Photo displayed in the view.

Managing Playback

var playbackGestureRecognizer: UIGestureRecognizer

A gesture recognizer that controls playback of the Live Photo in the view.

var isMuted: Bool

A Boolean value that determines whether the view plays the audio content of its Live Photo.

var audioVolume: Float

The audio gain to apply to the Live Photo’s movie content during playback.

Responding to Playback Events

var delegate: PHLivePhotoViewDelegate?

An object to be notified when Live Photo playback begins or ends.

Manually Playing Live Photo Content

func startPlayback(with: PHLivePhotoViewPlaybackStyle)

Begins playback of Live Photo content in the view.

func stopPlayback()

Ends playback of Live Photo content in the view.

Accessing User Interface Icons for Live Photos

class func livePhotoBadgeImage(options: PHLivePhotoBadgeOptions = [])

Returns an icon image for the specified Live Photo semantic options.

var livePhotoBadgeView: NSView?

A view for displaying Live Photo status.

Constants

enum PHLivePhotoViewPlaybackStyle

Options for how much of the motion and sound content of a Live Photo to play, used in the startPlayback(with:) method and in messages to the view’s delegate object.

struct PHLivePhotoBadgeOptions

Options for the semantic use and display style of icons for badging Live Photo assets, used by the livePhotoBadgeImage(options:) method.