UIView with a Dashed line
What I have: To create this line, I basically have an UIView and I do the following: void setLayerToLineFromAToB(CALayer *layer, CGPoint a, CGPoint b, CGFloat lineWidth) { CGPoint center = { 0.5 * (a.x + b.x), 0.5 * (a.y + b.y) }; CGFloat length = sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); CGFloat angle = atan2(a.y - b.y, a.x - b.x); layer.position = center; layer.bounds = (CGRect) { {0, 0}, { length + lineWidth, lineWidth } }; layer.transform = CATransform3DMakeRotation(angle, 0, 0, 1); } Note: This code was found here on stackoverflow, so if someone can give me the