---
title: "field(evaluationBlock:)"
framework: uikit
role: symbol
role_heading: Type Method
path: "uikit/uifieldbehavior/field(evaluationblock:)"
---

# field(evaluationBlock:)

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

## Declaration

```swift
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:

## Return Value

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

## Discussion

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.

## See Also

### Getting the field behaviors

- [dragField()](uikit/uifieldbehavior/dragfield().md)
- [springField()](uikit/uifieldbehavior/springfield().md)
- [velocityField(direction:)](uikit/uifieldbehavior/velocityfield(direction:).md)
- [electricField()](uikit/uifieldbehavior/electricfield().md)
- [magneticField()](uikit/uifieldbehavior/magneticfield().md)
- [radialGravityField(position:)](uikit/uifieldbehavior/radialgravityfield(position:).md)
- [linearGravityField(direction:)](uikit/uifieldbehavior/lineargravityfield(direction:).md)
- [vortexField()](uikit/uifieldbehavior/vortexfield().md)
- [noiseField(smoothness:animationSpeed:)](uikit/uifieldbehavior/noisefield(smoothness:animationspeed:).md)
- [turbulenceField(smoothness:animationSpeed:)](uikit/uifieldbehavior/turbulencefield(smoothness:animationspeed:).md)
