Instance Method

initWithItem:offsetFromCenter:attachedToItem:offsetFromCenter:

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

Declaration

- (instancetype)initWithItem:(id<UIDynamicItem>)item1 offsetFromCenter:(UIOffset)offset1 attachedToItem:(id<UIDynamicItem>)item2 offsetFromCenter:(UIOffset)offset2;

Parameters

item1

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

p1

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

item2

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

p2

The offset from the center of item2 at which to create the attachment. Specifying UIOffsetZero 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 UIAttachmentBehaviorTypeItems.

See Also

Creating and Initializing Attachment Behavior Objects

+ slidingAttachmentWithItem:attachmentAnchor:axisOfTranslation:

Creates and returns an attachment behavior where one item slides along the specified axis.

+ slidingAttachmentWithItem:attachedToItem:attachmentAnchor:axisOfTranslation:

Creates and returns an attachment behavior where two items are fixed to points that slide along the specified axis.

+ fixedAttachmentWithItem:attachedToItem:attachmentAnchor:

Creates and returns an attachment behavior where the two items are fixed together through the specified anchor point.

+ limitAttachmentWithItem:offsetFromCenter:attachedToItem:offsetFromCenter:

Creates and returns an attachment behavior object where two items are constrained by a maximum distance from one another.

+ pinAttachmentWithItem:attachedToItem:attachmentAnchor:

Creates and returns an attachment behavior where the two items are pinned to, and move around, an anchor point

- initWithItem:attachedToAnchor:

Initializes a behavior where the center of a dynamic item is attached to the specified anchor point.

- initWithItem:attachedToItem:

Initializes a behavior where the centers of two dynamic items are attached to each other.

- initWithItem:offsetFromCenter:attachedToAnchor:

Initializes a behavior where the specified point in a dynamic item is attached to an anchor point.