Creates a bitmap-based graphics context and makes it the current context.


func UIGraphicsBeginImageContext(_ size: CGSize)



The size of the new bitmap context. This represents the size of the image returned by the UIGraphicsGetImageFromCurrentImageContext() function.


This function is equivalent to calling the UIGraphicsBeginImageContextWithOptions(_:_:_:) function with the opaque parameter set to false and a scale factor of 1.0.

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

See Also

Image Creation

func UIGraphicsGetImageFromCurrentImageContext() -> UIImage?

Returns an image based on the contents of the current bitmap-based graphics context.

func UIGraphicsEndImageContext()

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

func jpegData(compressionQuality: CGFloat) -> Data?

Returns the data for the specified image in JPEG format.

func pngData() -> Data?

Returns the data for the specified image in PNG format