iOS Developer Library — Pre-Release

Developer

UIKit Framework Reference UIAttachmentBehavior Class Reference

Options
Deployment Target:

On This Page
Language:

UIAttachmentBehavior

An attachment behavior specifies a dynamic connection between two dynamic items, or between a dynamic item and an anchor point. By default, an item’s attachment point is at its center, but you can change that. More...

Inheritance


Conforms To


Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 7.0 and later.
  • items items Property

    The dynamic items connected by the attachment behavior. (read-only)

    Declaration

    Swift

    var items: [AnyObject] { get }

    Objective-C

    @property(nonatomic, readonly, copy) NSArray *items

    Discussion

    Contains two elements when used for an attachment behavior of type UIAttachmentBehaviorTypeItems; contains one element when used for an attachment behavior of type UIAttachmentBehaviorTypeAnchor.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Initializes an attachment behavior that connects the center point of a dynamic item to an anchor point.

    Declaration

    Swift

    convenience init!(item item: UIDynamicItem, attachedToAnchor point: CGPoint)

    Objective-C

    - (instancetype)initWithItem:(id<UIDynamicItem>)item attachedToAnchor:(CGPoint)point

    Parameters

    item

    The dynamic item to which you are applying an attachment behavior.

    point

    The anchor point for the attachment behavior, relative to the coordinate system for the behavior’s associated dynamic animator. For more information, see the Overview in UIDynamicAnimator Class Reference.

    Return Value

    The initialized attachment behavior, or nil if there was a problem initializing the object.

    Discussion

    Used for attachment behaviors of type UIAttachmentBehaviorTypeAnchor.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Initializes an attachment behavior that connects the center point of a dynamic item to the center point of another dynamic item.

    Declaration

    Swift

    convenience init!(item item1: UIDynamicItem, attachedToItem item2: UIDynamicItem)

    Objective-C

    - (instancetype)initWithItem:(id<UIDynamicItem>)item1 attachedToItem:(id<UIDynamicItem>)item2

    Parameters

    item1

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

    item2

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

    Return Value

    The initialized attachment behavior, or nil if there was a problem initializing the object

    Discussion

    Used for attachment behaviors of type UIAttachmentBehaviorTypeItems.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Initializes an attachment behavior that connects a specified point in a dynamic item to an anchor point.

    Declaration

    Swift

    convenience init!(item item: UIDynamicItem, offsetFromCenter p1: UIOffset, attachedToAnchor point: CGPoint)

    Objective-C

    - (instancetype)initWithItem:(id<UIDynamicItem>)item offsetFromCenter:(UIOffset)p1 attachedToAnchor:(CGPoint)point

    Parameters

    item

    The dynamic item to which you are applying an attachment behavior.

    p1

    The point, within the dynamic item and described as an offset from its center point, for the attachment behavior.

    point

    The anchor point for the attachment behavior, relative to the coordinate system for the behavior’s associated dynamic animator. For more information, see the Overview in UIDynamicAnimator Class Reference.

    Return Value

    The initialized attachment behavior, or nil if there was a problem initializing the object.

    Discussion

    Used for attachment behaviors of type UIAttachmentBehaviorTypeAnchor.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

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

    Declaration

    Swift

    init!(item item1: UIDynamicItem, offsetFromCenter p1: UIOffset, attachedToItem item2: UIDynamicItem, offsetFromCenter p2: UIOffset)

    Objective-C

    - (instancetype)initWithItem:(id<UIDynamicItem>)item1 offsetFromCenter:(UIOffset)p1 attachedToItem:(id<UIDynamicItem>)item2 offsetFromCenter:(UIOffset)p2

    Parameters

    item1

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

    p1

    The point, within the first dynamic item and described as an offset from its center point, for the attachment.

    item2

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

    p2

    The point, within the second dynamic item and described as an offset from its center point, for the attachment.

    Return Value

    The initialized attachment behavior, or nil if there was a problem initializing the object.

    Discussion

    This is the designated initializer for the UIAttachmentBehavior class.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • The anchor point for an attachment behavior of type UIAttachmentBehaviorTypeAnchor.

    Declaration

    Swift

    var anchorPoint: CGPoint

    Objective-C

    @property(readwrite, nonatomic) CGPoint anchorPoint

    Discussion

    The anchor point is relative to the coordinate system for the behavior’s associated dynamic animator. For more information, see the Overview in UIDynamicAnimator Class Reference.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • The type of the attachment behavior. (read-only)

    Declaration

    Swift

    var attachedBehaviorType: UIAttachmentBehaviorType { get }

    Objective-C

    @property(readonly, nonatomic) UIAttachmentBehaviorType attachedBehaviorType

    Discussion

    The available types for attachment behaviors are described in the UIAttachmentBehaviorType enum.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • damping damping Property

    The amount of damping to apply to the attachment behavior.

    Declaration

    Swift

    var damping: CGFloat

    Objective-C

    @property(readwrite, nonatomic) CGFloat damping

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • frequency frequency Property

    The frequency of oscillation for the attachment behavior.

    Declaration

    Swift

    var frequency: CGFloat

    Objective-C

    @property(readwrite, nonatomic) CGFloat frequency

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • length length Property

    The distance, in points, between the two attachment points of the attachment behavior.

    Declaration

    Swift

    var length: CGFloat

    Objective-C

    @property(readwrite, nonatomic) CGFloat length

    Discussion

    Use this property to adjust the attachment length, if you want to, after creating an attachment. The system sets initial length automatically based on how you initialize the attachment.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • The type of an attachment behavior, indicating what a dynamic item is attached to.

    Declaration

    Swift

    enum UIAttachmentBehaviorType : Int { case Items case Anchor }

    Objective-C

    typedef enum { UIAttachmentBehaviorTypeItems, UIAttachmentBehaviorTypeAnchor } UIAttachmentBehaviorType;

    Constants

    • Items

      UIAttachmentBehaviorTypeItems

      Designates an attachment behavior that connects a dynamic item to another dynamic item.

      Available in iOS 7.0 and later.

    • Anchor

      UIAttachmentBehaviorTypeAnchor

      Designates an attachment behavior that connects a dynamic item to an anchor point.

      Available in iOS 7.0 and later.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.