<!--
{
  "availability" : [
    "iOS: 2.0.0 - 27.0.0",
    "iPadOS: 2.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "tvOS: -",
    "visionOS: 1.0.0 - 27.0.0",
    "watchOS: 2.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIGraphicsEndImageContext()",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:@F@UIGraphicsEndImageContext"
  },
  "title" : "UIGraphicsEndImageContext()"
}
-->

# UIGraphicsEndImageContext()

Removes the current bitmap-based graphics context from the top of the stack.

```
func UIGraphicsEndImageContext()
```

## Discussion

You use this function to clean up the drawing environment put in place by the [`UIGraphicsBeginImageContext(_:)`](/documentation/UIKit/UIGraphicsBeginImageContext(_:)) function and to remove the corresponding bitmap-based graphics context from the top of the stack. If the current context was not created using the [`UIGraphicsBeginImageContext(_:)`](/documentation/UIKit/UIGraphicsBeginImageContext(_:)) function, this function does nothing.

This function may be called from any thread of your app.

---

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)