Contents

init(id:_:)

Creates an new attachment from an identifier and a closure.

Declaration

nonisolated init(id: AnyHashable, @ViewBuilder _ content: @escaping () -> Content)

Parameters

  • id:

    An AnyHashable instance that identifies the attachment and a Viewattachmententity.

  • content:

    A ViewBuilder instance that contains the views for the attachment.

Discussion

You can access details of an attachment entity, such as its bounds, by calling the methods of a ViewAttachmentEntity instance. For example, you can add an attachment that contains the text "hello".

Attachment(id: "example") {
    Text("hello")
}