首页 > 解决方案 > CAShapeLayer dashed line start with margin

问题描述

Is it possible to start drawing dashed CAShapeLayer line with some margin? I am connect couple dashed lines at an angle.

It would be great if my dash could start at half dash length. So if

lineDashPattern = [8, 8]

then dash line should start drawing with 4 margin

标签: ioscashapelayer

解决方案


You should use lineDashPhase. It specifies an offset, in user space applied to the line dash pattern

Line dash phase specifies how far into the dash pattern the line starts.

shapeLayer1.lineDashPhase = 8

enter image description here


推荐阅读