I've been thinking about this one for a while. Basically, the code below draws a border on a UIView, but, if I add another UIView as a subview to that UIView - it'll appear above the border.
Like this:
How do I (as cleanly as possible), keep the border above all subviews?
Like this:
This is what I have so far. But, like stated above, it doesn't keep the border above all its subviews.
    CGPathRef CGPathRect = CGPathCreateWithRect(rect, 0);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGPathRef border = CGPathCreateCopyByStrokingPath(rect.CGPath, NULL, 5.0f, kCGLineCapButt, kCGLineJoinMiter, 0);
    CGContextAddPath(context, border);
    CGContextSetFillColorWithColor(context, someCGColor);
    CGContextDrawPath(context, kCGPathFill);
    CGPathRelease(border);
I could create a separate UIView for the border itself, and just insert subviews below that UIView, but that feels rather hackish. If there's a better way - I'd love to hear about it.

