<!--
{
  "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/field(evaluationBlock:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIFieldBehavior(cm)fieldWithEvaluationBlock:"
  },
  "title" : "field(evaluationBlock:)"
}
-->

# field(evaluationBlock:)

Creates and returns a field behavior object that applies an app-specified field to items.

```
class func field(evaluationBlock block: @escaping (UIFieldBehavior, CGPoint, CGVector, CGFloat, CGFloat, TimeInterval) -> CGVector) -> Self
```

## Parameters

`block`

The block to execute to compute the instantaneous force of the field on an item. This block returns a CGVector object that reflects the direction and magnitude of the force to apply. The block takes the following parameters:

- field: The field behavior object being evaluated.
- position: The point at which to compute the force value, in the reference coordinate system. The position corresponds to the location of an item in the field.
- velocity: The velocity to be considered during evaluation of the force. Usually, this is the velocity of an item in the field. The vector reflects both the direction and magnitude of the velocity.
- mass: The mass value to be used in any force computations. Use this value in fields where the applied forces vary with the mass of the object.
- charge: The charge value to be used in any force computations. Use this value in fields where the applied forces vary with the charge of the object.
- deltaTime: The amount of time that has passed since the last time the force value for this item was computed.

## Return Value

A field behavior object that applies forces based on the custom algorithm you provided.

## Discussion

Use this method to define a custom field for your app. The block you provide is called many times during the course of animations, so your implementation should be reasonably fast. Use the provided `field` object to retrieve values associated with the field itself, such as the field’s position and strength. The other parameters reflect information about the dynamic item affected by the field.

---

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)