<!--
{
  "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/UICollisionBehavior/addBoundary(withIdentifier:from:to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UICollisionBehavior(im)addBoundaryWithIdentifier:fromPoint:toPoint:"
  },
  "title" : "addBoundary(withIdentifier:from:to:)"
}
-->

# addBoundary(withIdentifier:from:to:)

Adds a collision boundary, specified as a line segment, to the collision behavior.

```
func addBoundary(withIdentifier identifier: any NSCopying, from p1: CGPoint, to p2: CGPoint)
```

## Parameters

`identifier`

An arbitrary identifier for the boundary you are adding.

`p1`

The starting point for the boundary line segment.

`p2`

The ending point for the boundary line segment.

## Discussion

This is a convenience method based on the [`addBoundary(withIdentifier:for:)`](/documentation/UIKit/UICollisionBehavior/addBoundary(withIdentifier:for:)) method. The coordinate system and origin point for the `p1` and `p2` parameters depend on how you’ve initialized the dynamic animator (that you’re adding the behavior to). See the overview in [`UIDynamicAnimator`](/documentation/UIKit/UIDynamicAnimator) for more information.

---

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)