I think there are two problems with that approach (mixing layer border and shape stroke)
- The border is on the inside (of the bounds) but the stroke is made from the center (of the path).
- The border is drawn after the path is stoked
You can do something about #1 by inseting the path half of the strokeWidth
CGFloat halfWidth = 1.0/2.0;
CGPathAddRect(path, NULL, CGRectInset(shapeLayer.bounds, halfWidth, halfWidth));
However the border is still going to be drawn above the shape (at least I don't know how change the order).
I think the easiest solution is to have to shape layers in the same container layer. The container would be used to change the frame and the two layers would be used to the drawing.
The bottom layer would have a white stroke (no dash pattern) and the top layer would have a dashed black stroke. Since both shapes would have the same path it would look like a black and white dash pattern.
Doing it this way would also work with any shape.