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
- CALayer Fundamentals
- Implicit and Explicit Animations
- Transforms and 3D Effects
- Custom Drawing with Core Graphics