iOS Developer Library

Developer

UIKit Framework Reference UISnapBehavior Class Reference

Options
Deployment Target:

On This Page
Language:

UISnapBehavior

A snap behavior defines a dynamic item’s movement to a specified point; the movement proceeds with a spring-like effect, ending with an oscillation whose amount you can set. More...

Inheritance


Conforms To


Import Statement


import UIKit @import UIKit;

Availability


Available in iOS 7.0 and later.
  • Initializes a snap behavior with a dynamic item and a snap point.

    Declaration

    Swift

    init!(item item: UIDynamicItem, snapToPoint point: CGPoint)

    Objective-C

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

    Parameters

    item

    The dynamic item that you want to apply a snap behavior to.

    point

    The point that you want the dynamic item to snap to. The coordinate system for the point parameter depends on how you initialize the dynamic animator you’re adding the snap behavior to, as described in the overview of UIDynamicAnimator Class Reference.

    Return Value

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

    Discussion

    At the conclusion of a snap, the rotation value (as indicated by the transform property) for a dynamic item is 0.

    Import Statement

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • damping damping Property

    The amount of oscillation of a dynamic item during the conclusion of a snap.

    Declaration

    Swift

    var damping: CGFloat

    Objective-C

    @property(nonatomic, assign) CGFloat damping

    Discussion

    The valid range for damping extends from 0.0, for minimum oscillation, through 1.0, for maximum oscillation. The default value is 0.5.

    Import Statement

    import UIKit

    Availability

    Available in iOS 7.0 and later.