Recall & Review
beginner
What is a Path in SwiftUI?
A
Path is a shape made by connecting lines and curves. It defines the outline of a custom shape you can draw on the screen.Click to reveal answer
beginner
How do you start drawing a custom shape in SwiftUI?
You create a struct that conforms to the
Shape protocol and implement the path(in rect: CGRect) -> Path method to define your shape.Click to reveal answer
beginner
What does the
move(to:) method do in a Path?It moves the drawing cursor to a new point without drawing a line, like lifting a pen and placing it somewhere else on paper.
Click to reveal answer
beginner
How do you add a straight line to a Path?
Use the
addLine(to:) method to draw a straight line from the current point to a new point.Click to reveal answer
beginner
Why use custom shapes instead of built-in shapes?
Custom shapes let you create unique designs and visuals that built-in shapes like circles or rectangles can't provide.Click to reveal answer
Which protocol must a struct conform to for creating a custom shape in SwiftUI?
✗ Incorrect
To create a custom shape, your struct must conform to the Shape protocol.
What does the
path(in rect: CGRect) method return?✗ Incorrect
The method returns a Path that defines the outline of the shape.
Which method moves the drawing cursor without drawing a line?
✗ Incorrect
move(to:) moves the cursor without drawing, like lifting a pen.
How do you close a path to connect the last point to the first?
✗ Incorrect
closeSubpath() closes the current path by connecting the last point to the first.
Which of these is NOT a method to add to a Path?
✗ Incorrect
There is no addText(string:) method for Path; text is handled differently.
Explain how to create a simple custom triangle shape in SwiftUI using Path.
Think about moving to the first point, drawing lines to the other points, and closing the shape.
You got /5 concepts.
Describe the difference between move(to:) and addLine(to:) when drawing a path.
Imagine drawing with a pen on paper.
You got /3 concepts.