0
0
iOS Swiftmobile~5 mins

Canvas for drawing in iOS Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AviewDidLoad()
Binit()
ClayoutSubviews()
Ddraw(_ rect: CGRect)
What class helps you create shapes and lines for drawing?
AUILabel
BUIBezierPath
CUIButton
DUIImageView
How do you tell the Canvas to refresh its drawing?
AsetNeedsDisplay()
BreloadData()
Crefresh()
Dupdate()
What happens if you draw outside the draw(_ rect:) method?
ADrawing may not appear or cause issues
BThe app crashes
CDrawing always appears immediately
DThe system ignores the drawing
Which UIKit class do you subclass to create a custom Canvas?
AUIScrollView
BUITableView
CUIView
DUIViewController
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.