previewDisplayName(_:)
Sets a user visible name to show in the canvas for a preview.
Declaration
nonisolated func previewDisplayName(_ value: String?) -> some View
Parameters
- value:
A name for the preview.
Return Value
A preview that uses the given name.
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")
}
}[Image]
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.