PreviewType

public enum PreviewType

The preview type to use to display an element in an Xcode preview.

We provide three preview types: A specific device type, a fixed size, and the size that fits the view.

  • The preview will be inside the provided device (eg, iPhone X).

    Note: You can use the provided extension on PreviewDevice to access devices in a type-safe way, eg: .device(.iPhone7).

    Declaration

    Swift

    case device(PreviewDevice)
  • The preview will be the provided size

    Declaration

    Swift

    case fixed(width: CGFloat, height: CGFloat)
  • The preview will be as large as needed to preview the content.

    Declaration

    Swift

    case thatFits(padding: CGFloat = 10.0)
  • Declaration

    Swift

    public var identifier: AnyHashable { get }
  • Declaration

    Swift

    public func previewView(
        with name: String,
        for element: Element
    ) -> AnyView