<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSAffineTransform",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAffineTransform"
  },
  "title" : "NSAffineTransform"
}
-->

# NSAffineTransform

A graphics coordinate transformation.

```
class NSAffineTransform
```

## Overview

In Swift, this object bridges to [`AffineTransform`](/documentation/Foundation/AffineTransform); use [`NSAffineTransform`](/documentation/Foundation/NSAffineTransform) when you need reference semantics or other Foundation-specific behavior.

A transformation specifies how points in one coordinate system are transformed to points in another coordinate system. An affine transformation is a special type of transformation that preserves parallel lines in a path but does not necessarily preserve lengths or angles. Scaling, rotation, and translation are the most commonly used manipulations supported by affine transforms, but shearing is also possible.

> Note:
> In OS X 10.3 and earlier the ``doc://com.apple.foundation/documentation/Foundation/NSAffineTransform`` class was declared and implemented entirely in the Application Kit framework. As of macOS 10.4 the ``doc://com.apple.foundation/documentation/Foundation/NSAffineTransform`` class has been split across the Foundation and Application Kit frameworks.

Methods for applying affine transformations to the current graphics context and a method for applying an affine transformation to an <doc://com.apple.documentation/documentation/AppKit/NSBezierPath> object are described in NSAffineTransform Additions Reference in the Application Kit.

> Important:
> The Swift overlay to the Foundation framework provides the ``doc://com.apple.foundation/documentation/Foundation/AffineTransform`` structure, which bridges to the ``doc://com.apple.foundation/documentation/Foundation/NSAffineTransform`` class. For more information about value types, see <doc://com.apple.documentation/documentation/Swift/working-with-foundation-types>.

## Topics

### Creating an Affine Transform

[`+  transform`](/documentation/Foundation/NSAffineTransform/transform)

Creates a new affine transform initialized to the identity matrix.

[`-  init`](/documentation/Foundation/NSAffineTransform/init())

Initializes an affine transform matrix to the identity matrix.

[`-  initWithTransform:`](/documentation/Foundation/NSAffineTransform/init(transform:))

Initializes the receiver’s matrix using another transform object.

### Accumulating Transformations

[`-  rotateByDegrees:`](/documentation/Foundation/NSAffineTransform/rotate(byDegrees:))

Applies a rotation factor (measured in degrees) to the receiver’s transformation matrix.

[`-  rotateByRadians:`](/documentation/Foundation/NSAffineTransform/rotate(byRadians:))

Applies a rotation factor (measured in radians) to the receiver’s transformation matrix.

[`-  scaleBy:`](/documentation/Foundation/NSAffineTransform/scale(by:))

Applies the specified scaling factor along both x and y axes to the receiver’s transformation matrix.

[`-  scaleXBy:yBy:`](/documentation/Foundation/NSAffineTransform/scaleX(by:yBy:))

Applies scaling factors to each axis of the receiver’s transformation matrix.

[`-  translateXBy:yBy:`](/documentation/Foundation/NSAffineTransform/translateX(by:yBy:))

Applies the specified translation factors to the receiver’s transformation matrix.

[`-  appendTransform:`](/documentation/Foundation/NSAffineTransform/append(_:))

Appends the specified matrix to the receiver’s matrix.

[`-  prependTransform:`](/documentation/Foundation/NSAffineTransform/prepend(_:))

Prepends the specified matrix to the receiver’s matrix.

[`-  invert`](/documentation/Foundation/NSAffineTransform/invert())

Replaces the receiver’s matrix with its inverse matrix.

### Transforming Data and Objects

[`-  transformPoint:`](/documentation/Foundation/NSAffineTransform/transform(_:)-41p16)

Applies the receiver’s transform to the specified point and returns the result.

[`-  transformSize:`](/documentation/Foundation/NSAffineTransform/transform(_:)-5r6ol)

Applies the receiver’s transform to the specified size and returns the results.

[`-  transformBezierPath:`](/documentation/Foundation/NSAffineTransform/transform(_:)-6z1xo)

Creates and returns a new Bézier path object with each point in the given path transformed by the receiver.

### Accessing the Transformation Matrix

[`transformStruct`](/documentation/Foundation/NSAffineTransform/transformStruct)

The matrix coefficients stored as the transformation matrix.

[`NSAffineTransformStruct`](/documentation/Foundation/NSAffineTransformStruct)

A structure that defines the three-by-three matrix that performs an affine transform between two coordinate systems.

### Setting and Building the Current Transformation Matrix

[`-  set`](/documentation/Foundation/NSAffineTransform/set())

Sets the current transformation matrix to the receiver’s transformation matrix.

[`-  concat`](/documentation/Foundation/NSAffineTransform/concat())

Appends the receiver’s matrix to the current transformation matrix stored in the current graphics context, replacing the current transformation matrix with the result.

## Relationships

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`Copyable`](/documentation/Swift/Copyable)

[`Equatable`](/documentation/Swift/Equatable)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Hashable`](/documentation/Swift/Hashable)

[`Escapable`](/documentation/Swift/Escapable)

[`NSCoding`](/documentation/Foundation/NSCoding)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)