<!--
{
  "availability" : [
    "macOS: 10.0.0 - 10.10.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSView/setUpGState()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSView(im)setUpGState"
  },
  "title" : "setUpGState()"
}
-->

# setUpGState()

Overridden by subclasses to (re)initialize the view’s graphics state object.

```
func setUpGState()
```

## Discussion

This method is automatically invoked when the graphics state object created using [`allocateGState()`](/documentation/AppKit/NSView/allocateGState()) needs to be initialized. The default implementation does nothing. Your subclass can override it to set the current font, line width, or any other graphics state parameter except coordinate transformations and the clipping path—these are established by the frame and bounds rectangles and by methods such as [`scaleUnitSquare(to:)`](/documentation/AppKit/NSView/scaleUnitSquare(to:)) and [`translateOrigin(to:)`](/documentation/AppKit/NSView/translateOrigin(to:)). Note that `drawRect:` can further transform the coordinate system and clipping path for whatever temporary effects it needs.

---

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)