Chapter 10
Drawings and Special Effects
IN THIS CHAPTER
Drawing using the five built-in shapes
Apply clippings to views using shapes
Drawing custom shapes
Using special effects
One of the core strengths of iOS is its superior graphic and animation capabilities. As an iOS developer, you can leverage Apple’s key frameworks for drawings and animations: Core Animation and Metal. However, some frameworks can be pretty low level. In SwiftUI, you can make use of these frameworks without getting yourself knee-deep in the details of these application programming interfaces (APIs).
In this chapter, I show you how to:
- Draw basic shapes using the five built-in shapes in SwiftUI
- Perform clippings on views
- Draw your own custom shapes
- Use the special effects on views
Drawing Using the Five Built-in Shapes
SwiftUI comes with five built-in basic shapes that are most commonly used by developers for drawing:
- Rectangle
- Rounded rectangle
- Circle
- Capsule
- Ellipse
Rectangles
To draw a rectangle, use the Rectangle
struct:
struct ContentView: View {
var body: some View {
Rectangle()
.frame(width: ...
Get SwiftUI For Dummies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.