What is the difference between CGLayer, CALayer and CGContext?
Difference between CGLayer, CALayer and CGContext
2.9k Views Asked by rishu1992 AtThere are 2 best solutions below
On
CG in CGLayer stands for core graphics and CA in CALayer for core animation. These are indeed confusing.
CGLayer is provided by CoreGraphics.framework and its main use to draw vector objects of various geometric shapes like circle, rectangle, line etc. This provides for high performance graphics support with CPU rendering IIRC.
CALayer (provided by Quartz framework) is simply for content animation in your 'Views'. This is OpenGL based mostly that uses GPU.
CGContext (again provided by Quartz framework) - this content is copied from doc directly
A graphics context contains drawing parameters and all device-specific information needed to render the paint on a page to the destination, whether the destination is a window in an application, a bitmap image, a PDF document, or a printer. You can obtain a graphics context by using Quartz graphics context creation functions or by using higher-level functions provided in the Carbon, Cocoa, or Printing frameworks. Quartz provides creation functions for various flavors of Quartz graphics contexts including bitmap images and PDF. The Cocoa framework provides functions for obtaining window graphics contexts. The Printing framework provides functions that obtain a graphics context appropriate for the destination printer.
So, as a documentation says
CALayer from
QuartzCore frameworkisFor more info please look https://developer.apple.com/reference/quartzcore/calayer
CGLayer from
Core Graphics frameworkisFor more info please look https://developer.apple.com/reference/coregraphics/1666309-cglayer
CGContext from
Core Graphics frameworkisFor more info please look https://developer.apple.com/reference/coregraphics/1666363-cgcontext