Contents

init(item:offsetFromCenter:attachedTo:offsetFromCenter:)

Initializes an attachment behavior that connects a specified point in one dynamic item to a specified point in another dynamic item.

Declaration

init(item item1: any UIDynamicItem, offsetFromCenter offset1: UIOffset, attachedTo item2: any UIDynamicItem, offsetFromCenter offset2: UIOffset)

Parameters

  • item1:

    The first of two dynamic items connected by the attachment behavior.

  • offset1:

    The offset from the center of item1 at which to create the attachment. Specifying Zero creates the attachment at the center of item1.

  • item2:

    The second of two dynamic items connected by the attachment behavior.

  • offset2:

    The offset from the center of item2 at which to create the attachment. Specifying Zero creates the attachment at the center of item2.

Return Value

The initialized attachment behavior, or nil if there was a problem initializing the object.

Discussion

The behavior created by this method acts like a solid rod connecting the two items at the specified offsets from their center points. Forces applied to one item push or pull the other item accordingly. The items are free to rotate around each other but always remain the same distance apart.

The attachment object returned by this method is of type UIAttachmentBehavior.AttachmentType.items.

See Also

Creating and initializing attachment behavior objects