I’m doing some tests with rendering dashed / dotted lines like so:
For the dotted lines, as an example; I created them with this function:
func drawDottedLines() -> UIImage { let path = UIBezierPath() path.move(to: CGPoint(x: 10,y: 10)) path.addLine(to: CGPoint(x: 290,y: 10)) path.lineWidth = 8
let dots: [CGFloat] = [
0.01, // dot
path.lineWidth * 2, // gap
]
path.setLineDash(dots, count: dots.count, phase: 0)
path.lineCapStyle = CGLineCap.round
UIGraphicsBeginImageContextWithOptions(CGSize(width:300, height:20), false, 2)
UIColor.white.setFill()
UIGraphicsGetCurrentContext()!.fill(.infinite)
UIColor.black.setStroke()
path.stroke()
let image = UIGraphicsGetImageFromCurrentImageContext() ?? nil
UIGraphicsEndImageContext()
return image!
}
What I need to figure out how to do next, render some text in the middle of the lines, so they render like:
* * * * TEST * * * *
How would I do that?
