0

I know how to create a simple single line border around a UIView. However, I see that the XCode storyboard has a double lined white to gray border, and want to replicate this look.

Is there a way to add a double lined border with different colors to UIView using built in UIKit properties?

view.layer.borderWidth = 1
view.layer.borderColor = borderColor.cgColor
view.layer.masksToBounds = true

enter image description here

Alex Stone
  • 46,408
  • 55
  • 231
  • 407
  • just draw another view with the inset of the size of the line weight – Leo Dabus Jul 03 '18 at 13:04
  • simply add a sublayer with borderwidth and bordercolor and add it to your uiview. the frame or rect given to the sublayer at the time initialising should be less than the frame or rect of the uiview such that difference between sublayer rect width and height and uiview = borderwidth. – Y_Y Jul 03 '18 at 13:43
  • It's just seeing how many iOS and MacOS elements are written using their own frameworks, I was curious if there's something new which creates effect like this without the hassle of layers, nested subviews, etc. – Alex Stone Jul 03 '18 at 13:56

0 Answers0