Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
iOS Architecture  ›  Lesson

The Media Layer

Media 12 minThe Media layer provides drawing with Core Graphics, animation with Core Animation, image filters with Core Image, audio and video with AVFoundation and Core Audio, and direct GPU access with Metal.

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.

Matching TrailLog's media tasksStep 1 of 4
  1. "Draw" the elevation chart

    Drawing shapes and lines → Core Graphics, usually through UIBezierPath in 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.

quick drill

Which framework applies a sepia filter to a hike photo?

quick drill

Every UIKit view is backed by which kind of object?

quick drill

TrailLog wants to play a trail video with standard controls. Which framework is the natural fit?

quick drill

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.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainA finished-hike celebration

When a hike is finished, TrailLog shows a drawn trophy shape that bounces in, blurs the background photo, and plays a short cheer. Name the Media framework for each part and explain why Metal and Core Audio are not needed.