---
title: saveGraphicsState()
framework: appkit
role: symbol
role_heading: Instance Method
path: appkit/nsgraphicscontext/savegraphicsstate()-swift.method
---

# saveGraphicsState()

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

## Declaration

```swift
func saveGraphicsState()
```

## Discussion

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. Other attributes are accessed through appropriate objects such as NSAffineTransform, NSColor, and NSFont.

## See Also

### Managing the Graphics State

- [restoreGraphicsState()](appkit/nsgraphicscontext/restoregraphicsstate()-swift.type.method.md)
- [restoreGraphicsState()](appkit/nsgraphicscontext/restoregraphicsstate()-swift.method.md)
- [saveGraphicsState()](appkit/nsgraphicscontext/savegraphicsstate()-swift.type.method.md)
- [setGraphicsState(_:)](appkit/nsgraphicscontext/setgraphicsstate(_:).md)
