0Pricing
Swift Academy · Lesson

Custom Drawing with Core Graphics

Draw paths and shapes in draw(_:).

When to Draw Custom Content

When layers and images cannot express a shape—charts, signatures, custom controls—you draw it yourself with Core Graphics (Quartz 2D).

Overriding draw(_:)

Subclass UIView and override draw(_:). UIKit calls it with a configured context; you issue drawing commands there.

import UIKit
final class ChartView: UIView {
    override func draw(_ rect: CGRect) {
        // drawing commands go here
    }
}

All lessons in this course

  1. CALayer Fundamentals
  2. Implicit and Explicit Animations
  3. Transforms and 3D Effects
  4. Custom Drawing with Core Graphics
← Back to Swift Academy