<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIAttachmentBehavior/init(item:offsetFromCenter:attachedTo:offsetFromCenter:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIAttachmentBehavior(im)initWithItem:offsetFromCenter:attachedToItem:offsetFromCenter:"
  },
  "title" : "init(item:offsetFromCenter:attachedTo:offsetFromCenter:)"
}
-->

# 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.

```
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`](/documentation/UIKit/UIOffset/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`](/documentation/UIKit/UIOffset/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`](/documentation/UIKit/UIAttachmentBehavior/AttachmentType/items).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)