Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting multiple borders on UIView

As I cannot find any questions/answers for this, I imagine it is not possible.

Is there anyway to set multiple borders on a UIView.

I am currently setting a standard border with .layer.borderWidth and layer.borderColor. I am wondering if I can add a multiple strokes/borders effect to the view.

I need a border of 4.0f in white then another 1.0f in another color.

like image 220
StuartM Avatar asked Feb 15 '23 06:02

StuartM


1 Answers

Three solutions I can think of:

  • nest a UIView in another one, define one border for each;
  • draw the border yourself in -(void)drawRect;
  • use an UIImageView with a resizable; stretchable image of your borders as background (the best solution performance-wise).
like image 70
Cyrille Avatar answered Feb 25 '23 11:02

Cyrille