---
title: CAValueFunction
framework: quartzcore
role: symbol
role_heading: Class
path: quartzcore/cavaluefunction
---

# CAValueFunction

An object that provides a flexible method of defining animated transformations.

## Declaration

```swift
class CAValueFunction
```

## Overview

Overview You can use a value function to specify the individual components of an animated transform. For example, to create a basic animation that rotates a layer from 0° to 180° around its z-axis, you would create a CABasicAnimation object with a fromValue of 0, a toValue of pi, and a valueFunction of a CAValueFunction with a function name of rotateZ. The following code shows how you would create such a rotation and apply it to a CALayer named rotatingLayer. let rotateAnimation = CABasicAnimation() rotateAnimation.valueFunction = CAValueFunction(name: kCAValueFunctionRotateZ) rotateAnimation.fromValue = 0 rotateAnimation.toValue = Float.pi rotateAnimation.duration = 3 rotatingLayer.add(rotateAnimation,                   forKey: "transform") The value functions scale and translate require 3 values, for the individual x, y and z components. When working with these value functions, you specify the animation’s fromValue and toValue as arrays. The following code shows how you could animate a layer’s scale from 0 to 1 using a value function. let scaleAnimation = CABasicAnimation() scaleAnimation.valueFunction = CAValueFunction(name: kCAValueFunctionScale) scaleAnimation.fromValue = [0, 0, 0] scaleAnimation.toValue = [1, 1, 1] scaleAnimation.duration = 3 scalingLayer.add(scaleAnimation,                  forKey: "transform")

## Topics

### Getting Value Function Properties

- [name](quartzcore/cavaluefunction/name.md)

### Creating and Initializing Value Functions

- [init(name:)](quartzcore/cavaluefunction/init(name:).md)

### Constants

- [Rotate Value Functions](quartzcore/rotate-value-functions.md)
- [Scale Value Functions](quartzcore/scale-value-functions.md)
- [Translate Functions](quartzcore/translate-functions.md)

### Initializers

- [init(coder:)](quartzcore/cavaluefunction/init(coder:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)

## See Also

### Animation

- [CAAnimation](quartzcore/caanimation.md)
- [CAAnimationDelegate](quartzcore/caanimationdelegate.md)
- [CAPropertyAnimation](quartzcore/capropertyanimation.md)
- [CABasicAnimation](quartzcore/cabasicanimation.md)
- [CAKeyframeAnimation](quartzcore/cakeyframeanimation.md)
- [CASpringAnimation](quartzcore/caspringanimation.md)
- [CATransition](quartzcore/catransition.md)
