iOS Developer Library — Prerelease

Developer

UIKit Framework Reference UIDynamicItem Protocol Reference

Options
Deployment Target:

On This Page
Language:

UIDynamicItem

To make a custom object eligible to participate in UIKit Dynamics, adopt the UIDynamicItem protocol in the object’s class.

Starting in iOS 7, the UIView and UICollectionViewLayoutAttributes classes implement this protocol.

  • bounds bounds Required Property

    Called when a dynamic animator needs the bounds of the dynamic item. (read-only)

    Declaration

    Swift

    var bounds: CGRect { get }

    Objective-C

    @property(nonatomic, readonly) CGRect bounds

    Availability

    Available in iOS 7.0 and later.

  • center center Required Property

    The center point of the dynamic item.

    Declaration

    Swift

    var center: CGPoint { get set }

    Objective-C

    @property(nonatomic, readwrite) CGPoint center

    Discussion

    The dynamic animator (that the item is associated with) calls this method when it has computed a new center point for the item.

    Availability

    Available in iOS 7.0 and later.

  • transform transform Required Property

    The rotation of the dynamic item.

    Declaration

    Swift

    var transform: CGAffineTransform { get set }

    Objective-C

    @property(nonatomic, readwrite) CGAffineTransform transform

    Discussion

    UIKit Dynamics makes use only of the rotation value in this property.

    The dynamic animator (that the item is associated with) calls this method when it has computed a new rotation value for the item.

    Availability

    Available in iOS 7.0 and later.

  • The type of collision bounds associated with the item. (read-only)

    Declaration

    Swift

    optional var collisionBoundsType: UIDynamicItemCollisionBoundsType { get }

    Objective-C

    @property(nonatomic, readonly) UIDynamicItemCollisionBoundsType collisionBoundsType

    Discussion

    The dynamics system uses this property to determine how to evaluate collisions with the dynamic item. Rectangular and elliptical bounds are defined by the bounds property of the item. For custom collision bounds, the shape of the bounds are in the collisionBoundingPath property.

    The default value of this property is UIDynamicItemCollisionBoundsTypeRectangle.

    Availability

    Available in iOS 9.0 and later.

  • The path-based shape to use for the collision bounds. (read-only)

    Declaration

    Swift

    optional var collisionBoundingPath: UIBezierPath { get }

    Objective-C

    @property(nonatomic, readonly, nonnull) UIBezierPath *collisionBoundingPath

    Discussion

    When the collisionBoundsType property is UIDynamicItemCollisionBoundsTypePath, the object in this property is used as the collision bounds. The path object you create must represent a convex polygon with counter-clockwise or clockwise winding, and the path must not intersect itself. When creating the path, the point (0, 0) in the path corresponds to the item’s origin.

    Availability

    Available in iOS 9.0 and later.

  • Constants that indicate the shape of the item’s collision bounds.

    Declaration

    Swift

    enum UIDynamicItemCollisionBoundsType : UInt { case Rectangle case Ellipse case Path }

    Objective-C

    typedef enum UIDynamicItemCollisionBoundsType : NSUInteger { UIDynamicItemCollisionBoundsTypeRectangle, UIDynamicItemCollisionBoundsTypeEllipse , // radii will be determined from the items bounds width, height UIDynamicItemCollisionBoundsTypePath } UIDynamicItemCollisionBoundsType;

    Constants

    • Rectangle

      UIDynamicItemCollisionBoundsTypeRectangle

      Rectangular collision bounds.

      Available in iOS 9.0 and later.

    • Ellipse

      UIDynamicItemCollisionBoundsTypeEllipse

      Elliptical collision bounds. The shape of the ellipse is determined by the width and height of the item’s bounds property.

      Available in iOS 9.0 and later.

    • Path

      UIDynamicItemCollisionBoundsTypePath

      Path-based collision bounds. For this type, the shape is a UIBezierPath object stored in the item’s collisionBoundingPath property.

      Available in iOS 9.0 and later.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 9.0 and later.