Instance Method インスタンスメソッド

previewDisplayName(_:)

Sets a user visible name to show in the canvas for a preview.

Declaration 宣言

func previewDisplayName(_ value: String?) -> some View

Return Value 戻り値

A preview that uses the given name.

Parameters パラメータ

value

A name for the preview.

Discussion 議論

Apply this modifier to a view inside your PreviewProvider implementation to associate a display name with that view’s preview:


struct CircleImage_Previews: PreviewProvider {
    static var previews: some View {
        CircleImage()
            .previewDisplayName("Circle")
    }
}

A screenshot of the Xcode preview canvas cropped to just the top of a

Add a name when you have multiple previews together in the canvas that you need to tell apart. The default value is nil, in which case Xcode displays a default string.

See Also 参照

Preview Customization プレビューカスタマイゼーション