How to add a border outline to a UIView

UIView and its subclasses have a built-in way to draw a border around it using its underlying CALayer.

The below example shows you how to draw a 4-point black border around a view.

Since Xcode 6 we have now been able to create our very own subclasses that are editable in the storyboard.

The following example shows how to create a base that allows you to change the border width and color within the storyboard interface editor.

 

 

Then in the storyboard set a view to the subclass BaseView

 

 

Then pop over to the attributes inspector and you should now be able to see the custom values