How can I add a dashed line inside UIView?
My code:
let path = UIBezierPath()
let p0 = CGPointMake(CGRectGetMinX(view.bounds),
CGRectGetMidY(view.bounds))
path.moveToPoint(p0)
let p1 = CGPointMake(CGRectGetMaxX(view.bounds),
CGRectGetMidY(view.bounds))
path.addLineToPoint(p1)
let dashes: [ CGFloat ] = [ 16.0, 32.0 ]
path.setLineDash(dashes, count: dashes.count, phase: 0.0)
path.lineWidth = 8.0
path.lineCapStyle = .Butt
UIColor.magentaColor().set()
path.stroke()
view.setNeedsDisplay()
But it does not display anything.
I am getting this in the log:
CGContextSetLineDash: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.