pinAttachment(with:attachedTo:attachmentAnchor:)
Creates and returns an attachment behavior where the two items are pinned to, and move around, an anchor point
Declaration
class func pinAttachment(with item1: any UIDynamicItem, attachedTo item2: any UIDynamicItem, attachmentAnchor point: CGPoint) -> SelfParameters
- item1:
The first of two dynamic items connected by the attachment behavior.
- item2:
The second of two dynamic items connected by the attachment behavior.
- point:
The initial anchor point for each item. Specify this point in the coordinate system of the dynamic animator’s reference view. For more information about coordinate systems, see Uidynamicanimator.
Return Value
A new attachment object or nil if the object could not be created.
Discussion
The behavior created by this method acts like a solid rod connecting each item to the specified anchor point. Each item is free to rotate around the anchor point, inscribing a circle whose radius is the defined at creation time by the distance between point and the item’s center. When forces act on one or both items, the anchor point and other item also move accordingly. The anchor point of the attachment does not interact with collision boundaries.
Use the frictionTorque property to control the rotational behavior of the items. When the value of that property is 0, items rotate freely in response to almost any impulse. Adding torque increases the amount of force that must be applied to an item before it rotates.
Use the attachmentRange property to limit the amount of rotation for each item. This property lets you specify the minimum and maximum amount of rotation of the items from their starting positions.
See Also
Creating and initializing attachment behavior objects
slidingAttachment(with:attachmentAnchor:axisOfTranslation:)slidingAttachment(with:attachedTo:attachmentAnchor:axisOfTranslation:)fixedAttachment(with:attachedTo:attachmentAnchor:)limitAttachment(with:offsetFromCenter:attachedTo:offsetFromCenter:)init(item:attachedToAnchor:)init(item:attachedTo:)init(item:offsetFromCenter:attachedToAnchor:)init(item:offsetFromCenter:attachedTo:offsetFromCenter:)