I was able to draw a dashed box, using the following code:
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
CGRect shapeRect = CGRectMake(0.0f, 0.0f, 200.0f,
Swift, more compact:
func addDashedLine(fromPoint start: CGPoint, toPoint end:CGPoint) {
let line = CAShapeLayer()
let linePath = UIBezierPath()
linePath.moveToPoint(start)
linePath.addLineToPoint(end)
line.path = linePath.CGPath
line.strokeColor = UIColor.redColor().CGColor
line.lineWidth = 1
line.lineJoin = kCALineJoinRound
line.lineDashPattern = [4, 4]
self.layer.addSublayer(line)
}