---
title: UIGraphicsEndImageContext()
framework: uikit
role: symbol
role_heading: Function
path: uikit/uigraphicsendimagecontext()
---

# UIGraphicsEndImageContext()

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

## Declaration

```swift
func UIGraphicsEndImageContext()
```

## Discussion

Discussion You use this function to clean up the drawing environment put in place by the 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(_:) function, this function does nothing. This function may be called from any thread of your app.

## See Also

### Image creation

- [Supporting HDR images in your app](uikit/supporting-hdr-images-in-your-app.md)
- [jpegData(compressionQuality:)](uikit/uiimage/jpegdata(compressionquality:).md)
- [pngData()](uikit/uiimage/pngdata().md)
- [UIGraphicsBeginImageContext(_:)](uikit/uigraphicsbeginimagecontext(_:).md)
- [UIGraphicsGetImageFromCurrentImageContext()](uikit/uigraphicsgetimagefromcurrentimagecontext().md)
