<!--
{
  "availability" : [
    "macOS: 10.10.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSGraphicsContext/init(cgContext:flipped:)-9cbad",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSGraphicsContext(cm)graphicsContextWithCGContext:flipped:"
  },
  "title" : "init(cgContext:flipped:)"
}
-->

# init(cgContext:flipped:)

Creates a new graphics context from the specified Core Graphics context and the initial flipped state.

```
init(cgContext graphicsPort: CGContext, flipped initialFlippedState: Bool)
```

## Parameters

`graphicsPort`

The graphics port used to create the graphics-context object, as a <doc://com.apple.documentation/documentation/CoreGraphics/CGContext> (opaque type) object.

`initialFlippedState`

Specifies the receiver’s initial flipped state. This is the value returned by [`isFlipped`](/documentation/AppKit/NSGraphicsContext/isFlipped) when no view has focus.

## Return Value

The created [`NSGraphicsContext`](/documentation/AppKit/NSGraphicsContext) object, or `nil` if the object could not be created.

---

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)