<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIFieldBehavior/linearGravityField(direction:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIFieldBehavior(cm)linearGravityFieldWithVector:"
  },
  "title" : "linearGravityField(direction:)"
}
-->

# linearGravityField(direction:)

Creates and returns a field behavior object that models a linear gravitational force.

```
class func linearGravityField(direction: CGVector) -> Self
```

## Parameters

`direction`

The vector indicating the direction of the gravitational force. You can change this value later by modifying the [`direction`](/documentation/UIKit/UIFieldBehavior/direction) property.

## Return Value

A field behavior object that applies a directional gravitation force to items with mass.

## Discussion

This field creates a directional gravitational force that applies uniformly to all dynamic items with mass. When setting the [`strength`](/documentation/UIKit/UIFieldBehavior/strength) of the field, positive values attract items in the direction of the vector and negative values repel items. The force on a given item can be determined by the equation `F = ma`, where force equals the mass of the item multiplied by the acceleration imposed by the gravitational field, which with this type of field is constant.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)