The Media Layer
TrailLog draws an elevation chart, animates a badge when you finish a hike, adds a warm filter to summit photos, and plays a short voice memo. Four jobs, four different frameworks — all from the Media layer, which sits between Core Services and the user interface.
The rule
Draw with Core Graphics, move with Core Animation, filter with Core Image, play with AVFoundation.
The main Media frameworks, each with one job:
- Core Graphics (also called Quartz 2D) — 2D drawing: lines, paths, shapes, gradients, PDF. Its geometry types,
CGRect,CGPoint,CGFloat, appear all over UIKit. - Core Animation — every UIKit view is backed by a
CALayer. Core Animation composites those layers and animates their properties (position, opacity, scale) smoothly, handing the work to a separate render process. - Core Image — applies filters to images (
CIFilter): colour adjustments, blurs, face detection. It uses the GPU when it can. - AVFoundation — high-level audio and video: playing (
AVPlayer), recording, camera capture, editing. - Core Audio — the low-level audio engine under AVFoundation, for precise, low-latency sound work.
- Metal — direct, low-overhead access to the GPU for custom 3D graphics and parallel computation. Other frameworks, including Core Animation and Core Image, run on top of it.
// Core Graphics: draw the elevation line
let path = UIBezierPath()
path.move(to: CGPoint(x: 0, y: 80))
path.addLine(to: CGPoint(x: 120, y: 20))
// Core Animation: fade the badge in over half a second
badgeView.alpha = 0
UIView.animate(withDuration: 0.5) { badgeView.alpha = 1 }The shortcut
Name the verb of the task and match it to the framework. If you catch yourself reaching for Metal or Core Audio, check whether a higher framework already does the job.
"Draw" the elevation chart
Drawing shapes and lines → Core Graphics, usually through
UIBezierPathin UIKit.
The trap is confusing Core Graphics with Core Animation. Core Graphics produces a picture; Core Animation moves and combines layers that already have pictures.
Drills
Answer fast — trust the rule.
Which framework applies a sepia filter to a hike photo?
Every UIKit view is backed by which kind of object?
TrailLog wants to play a trail video with standard controls. Which framework is the natural fit?
When is Metal the right choice?
Remember
- Draw with Core Graphics, move with Core Animation, filter with Core Image, play with AVFoundation.
- Core Audio and Metal are the low-level engines underneath; use them only when you must.
- Trap: Core Graphics makes the picture; Core Animation moves and composites it.
