Instance Method


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


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



An arbitrary identifier for the boundary you are adding.


The starting point for the boundary line segment.


The ending point for the boundary line segment.


This is a convenience method based on the 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 for more information.

See Also

Configuring a Collision Behavior

func addBoundary(withIdentifier: NSCopying, for: UIBezierPath)

Adds a collision boundary, specified as a Bezier path, to the collision behavior.

var boundaryIdentifiers: [NSCopying]?

The set of boundary identifiers that you’ve added to the collision behavior.

func boundary(withIdentifier: NSCopying) -> UIBezierPath?

Returns a specified Bezier-path boundary.

var collisionMode: UICollisionBehavior.Mode

The type of edges that participate in collisions for the collision behavior.

func removeAllBoundaries()

Removes all previously-specified collision boundaries from the collision behavior.

func removeBoundary(withIdentifier: NSCopying)

Removes a specific collision boundary from the collision behavior.

func setTranslatesReferenceBoundsIntoBoundary(with: UIEdgeInsets)

Specifies a collision boundary based on the bounds of the animation reference system, with optional insets.

var translatesReferenceBoundsIntoBoundary: Bool

Specifies whether a boundary based on the reference system is active.