Complete the code to create a simple rectangle path using UIBezierPath.
let rect = CGRect(x: 10, y: 10, width: 100, height: 50) let path = UIBezierPath([1]: rect)
The UIBezierPath(rect:) initializer creates a rectangular path.
Complete the code to add a line from the current point to (100, 100) in the path.
let path = UIBezierPath() path.move(to: CGPoint(x: 0, y: 0)) path.[1](to: CGPoint(x: 100, y: 100))
The addLine(to:) method adds a straight line to the specified point.
Fix the error in the code to close the path properly.
let path = UIBezierPath() path.move(to: CGPoint(x: 0, y: 0)) path.addLine(to: CGPoint(x: 50, y: 0)) path.addLine(to: CGPoint(x: 50, y: 50)) path.[1]()
The closePath() method closes the current subpath by connecting the last point to the first.
Fill both blanks to create a rounded rectangle path with corner radius 10.
let rect = CGRect(x: 20, y: 20, width: 150, height: 100) let path = UIBezierPath([1]: rect, cornerRadius: [2])
The UIBezierPath(roundedRect:cornerRadius:) initializer creates a rectangle with rounded corners.
Fill all three blanks to create a quadratic curve from (0,0) to (100,100) with control point (50,0).
let path = UIBezierPath() path.move(to: CGPoint(x: 0, y: 0)) path.[1](to: CGPoint(x: 100, y: 100), controlPoint: CGPoint(x: [2], y: [3]))
The addQuadCurve(to:controlPoint:) method adds a quadratic BΓ©zier curve with one control point.