<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSGraphicsContext/saveGraphicsState()-swift.method",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSGraphicsContext(im)saveGraphicsState"
  },
  "title" : "saveGraphicsState()"
}
-->

# saveGraphicsState()

Saves the current graphics state and creates a new graphics state on the top of the stack.

```
func saveGraphicsState()
```

## Discussion

The new graphics state is a copy of the previous state that can be modified to handle new drawing operations.

Saving the graphics state saves such attributes as the current drawing style, transformation matrix, color, and font. To set drawing style attributes, use the methods of [`NSBezierPath`](/documentation/AppKit/NSBezierPath). Other attributes are accessed through appropriate objects such as <doc://com.apple.documentation/documentation/Foundation/NSAffineTransform>, [`NSColor`](/documentation/AppKit/NSColor), and [`NSFont`](/documentation/AppKit/NSFont).

---

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)