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.