Contents

Drawing and graphics

Enhance your views with graphical effects and customized drawings.

Overview

You create rich, dynamic user interfaces with the built-in views and Shapes that SwiftUI provides. To enhance any view, you can apply many of the graphical effects typically associated with a graphics context, like setting colors, adding masks, and creating composites.

[Image]

When you need the flexibility of immediate mode drawing in a graphics context, use a Canvas view. This can be particularly helpful when you want to draw an extremely large number of dynamic shapes — for example, to create particle effects.

For design guidance, see Materials and Color in the Human Interface Guidelines.

Topics

Immediate mode drawing

Setting a color

Styling content

Transforming colors

Scaling, rotating, or transforming a view

Masking and clipping

Applying blur and shadows

Applying effects based on geometry

Compositing views

Measuring a view

Responding to a geometry change

Accessing Metal shaders

Accessing geometric constructs

See Also

Views