iOS Developer Library — Pre-Release

Developer

UIKit Framework Reference UIGravityBehavior Class Reference

Options
Deployment Target:

On This Page
Language:

UIGravityBehavior

A gravity behavior specifies a gravity vector that applies to all of its dynamic items. More...

Inheritance


Conforms To


Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 7.0 and later.
  • Adds a dynamic item to the gravity behavior’s item array.

    Declaration

    Swift

    func addItem(_ item: UIDynamicItem)

    Objective-C

    - (void)addItem:(id<UIDynamicItem>)item

    Parameters

    item

    The dynamic item to add to the item array.

    Discussion

    All the dynamic items added to a gravity behavior are subject to the same gravity vector.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Initializes a gravity behavior with an array of dynamic items.

    Declaration

    Swift

    init(items items: [AnyObject])

    Objective-C

    - (instancetype)initWithItems:(NSArray *)items

    Parameters

    items

    The dynamic items that you want to be subject to the gravity behavior.

    Return Value

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

    Discussion

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Removes a specific dynamic item from the gravity behavior.

    Declaration

    Swift

    func removeItem(_ item: UIDynamicItem)

    Objective-C

    - (void)removeItem:(id<UIDynamicItem>)item

    Parameters

    item

    The dynamic item that you want to remove.

    Discussion

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • items items Property

    Returns the set of dynamic items you’ve added to the gravity behavior. (read-only)

    Declaration

    Swift

    var items: [AnyObject] { get }

    Objective-C

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

    Discussion

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • angle angle Property

    The angle, in radians, of the gravity vector for the behavior.

    Declaration

    Swift

    var angle: CGFloat

    Objective-C

    @property(readwrite, nonatomic) CGFloat angle

    Discussion

    The radian angle for this property conforms to standard UIKit geometry. To configure a gravity vector for a gravity behavior, set the magnitude property as well as the angle property.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • magnitude magnitude Property

    The magnitude of the gravity vector for the gravity behavior.

    Declaration

    Swift

    var magnitude: CGFloat

    Objective-C

    @property(readwrite, nonatomic) CGFloat magnitude

    Discussion

    A magnitude value of 1.0 represents an acceleration of 1000 points / second². To configure a gravity vector for a gravity behavior, set the angle property as well as the magnitude property.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Sets the angle and magnitude of the gravity vector for the behavior.

    Declaration

    Swift

    func setAngle(_ angle: CGFloat, magnitude magnitude: CGFloat)

    Objective-C

    - (void)setAngle:(CGFloat)angle magnitude:(CGFloat)magnitude

    Parameters

    angle

    The radian angle for the gravity vector, using standard UIKit geometry.

    magnitude

    The acceleration for the gravity, with a value of 1.0 corresponding to 1000 points / second².

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

    See Also

    angle
    magnitude

  • The direction for the gravity behavior’s gravity vector, expressed as an (x, y) pair.

    Declaration

    Swift

    var gravityDirection: CGVector

    Objective-C

    @property(readwrite, nonatomic) CGVector gravityDirection

    Discussion

    The default gravity vector expressed as an x, y pair is (0.0, 1.0), equivalent to no gravity component directed to the right and a downward component of 1000 points / second². A negative value in either component reverses the direction of the component.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

    See Also

    angle