Recall & Review
beginner
What is a Canvas in iOS Swift development?
A Canvas is a view or area where you can draw shapes, lines, or images using code. It acts like a blank paper for your app to create drawings.
Click to reveal answer
beginner
Which class in Swift is commonly used to create a custom drawing area?You use a <code>UIView</code> subclass and override its <code>draw(_ rect: CGRect)</code> method to perform custom drawing on the Canvas.Click to reveal answer
intermediate
What is the role of
UIBezierPath in drawing on Canvas?UIBezierPath helps you create paths like lines, curves, and shapes that you can stroke or fill on the Canvas.Click to reveal answer
intermediate
How do you trigger a Canvas to redraw its content?
Call
setNeedsDisplay() on the Canvas view to tell iOS to call draw(_ rect: CGRect) again and update the drawing.Click to reveal answer
intermediate
Why is it important to keep drawing code inside
draw(_ rect: CGRect)?Because iOS calls this method whenever the view needs to update. Drawing outside this method may not appear or cause performance issues.
Click to reveal answer
Which method do you override to draw on a UIView Canvas?
✗ Incorrect
The draw(_ rect: CGRect) method is where you put your drawing code for a UIView.
What class helps you create shapes and lines for drawing?
✗ Incorrect
UIBezierPath is used to create paths like lines and shapes for drawing.
How do you tell the Canvas to refresh its drawing?
✗ Incorrect
setNeedsDisplay() marks the view as needing to be redrawn, triggering draw(_ rect: CGRect).
What happens if you draw outside the draw(_ rect:) method?
✗ Incorrect
Drawing outside draw(_ rect:) may not show or cause performance problems.
Which UIKit class do you subclass to create a custom Canvas?
✗ Incorrect
You subclass UIView to create a custom drawing Canvas.
Explain how to create a simple drawing Canvas in iOS Swift.
Think about the steps to show custom lines or shapes on screen.
You got /4 concepts.
Describe why the draw(_ rect: CGRect) method is important for Canvas drawing.
Consider how iOS manages view updates.
You got /4 concepts.