---
title: "init(cgContext:flipped:)"
framework: appkit
role: symbol
role_heading: Initializer
path: "appkit/nsgraphicscontext/init(cgcontext:flipped:)-9cbad"
---

# init(cgContext:flipped:)

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

## Declaration

```swift
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 doc://com.apple.appkit/documentation/AppKit/NSGraphicsContext/isFlipped when no view has focus.

## Return Value

Return Value The created NSGraphicsContext object, or nil if the object could not be created.

## See Also

### Creating a Graphics Context

- [init(attributes:)](appkit/nsgraphicscontext/init(attributes:).md)
- [init(bitmapImageRep:)](appkit/nsgraphicscontext/init(bitmapimagerep:).md)
- [init(window:)](appkit/nsgraphicscontext/init(window:).md)
- [init(graphicsPort:flipped:)](appkit/nsgraphicscontext/init(graphicsport:flipped:).md)
