9.5 · Core Graphics, UIBezierPath and draw(_:)
Sometimes built-in views are not enough and you draw. Core Graphics turns code into pixels, and scale is the part people forget.
Mental model. Drawing is vector instructions turned into a bitmap at a given scale. Decide when it runs, how big the bitmap is, and whether you can cache it.
Custom drawing
<code>draw(_:)</code>, renderers and paths.
- How do you draw with Core Graphics and UIBezierPath, and how do scale and caching affect it?
Inside draw(_:), UIKit has already set up a current graphics context (UIGraphicsGetCurrentContext(), a CGContext) sized and scaled for the view. You build…
More in Layout, rendering & animation
- 9.1 · Auto Layout, intrinsic size, and when layoutSubviews and draw run
- 9.2 · From layout to the GPU, and the two layer trees
- 9.3 · Offscreen passes, rasterization, blending, shadows and masks
- 9.4 · Implicit and explicit animation, UIView animation, and animators
- 9.6 · TextKit 1 and 2, and Text in SwiftUI
- 9.7 · Frame budgets, ProMotion, hitches and hangs
- 9.8 · Margins, stack views, guides, constraint ownership, the layout cycle and measuring
- 9.9 · Coordinate conversion, 3D transforms and layer contents
- 9.10 · How UIView animation really works, springs, timing and display links
- 9.11 · Transform order, fill rules, text measurement, text containers and bitmaps
- 9.12 · Rectangle containment and moving a point between coordinate spaces