Class

LPLinkView

A rich visual representation of a link.

Declaration

iOS, Mac Catalyst
class LPLinkView : UIView
macOS
class LPLinkView : NSView

Overview

LPLinkView presents a link based on its available metadata. Use it to show a link’s title and icon, associated images, inline audio, video playback, and maps in a familiar and consistent style.

Present a Rich Link

To present a rich link in your app, create an LPLinkView, passing an LPLinkMetadata instance into its initializer. Then add the LPLinkView to your view.

For example, to present links in a table view, add an LPLinkView instance as a subview when populating each cell.

let linkView = LPLinkView(metadata: metadata)
cell.contentView.addSubview(linkView)
linkView.sizeToFit()

LPLinkView has an intrinsic size, but it also responds to sizeToFit() to present a layout at any size.

Topics

Creating a Link View

init(metadata: LPLinkMetadata)

Initializes a link view with specified metadata.

init(url: URL)

Initializes a placeholder link view without metadata for a given URL.

Specifying Metadata

var metadata: LPLinkMetadata

The metadata from which to generate a rich presentation.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software