In Xcode make sure Editor -> Automatically refresh views is checked.

Create a new Swift file.

import UIKit @IBDesignable class BoxView : UIView { override func prepareForInterfaceBuilder () { super . prepareForInterfaceBuilder () layer . borderColor = borderColor ? . cgColor layer . borderWidth = borderWidth layer . cornerRadius = cornerRadius } @IBInspectable var borderColor : UIColor ? { didSet { layer . borderColor = borderColor ? . cgColor setNeedsLayout () } } @IBInspectable var borderWidth : CGFloat = 0.0 { didSet { layer . borderWidth = borderWidth setNeedsLayout () } } @IBInspectable var cornerRadius : CGFloat = 0.0 { didSet { layer . cornerRadius = cornerRadius setNeedsLayout () } } }

Create a UIView in InterfaceBuilder. In the Identity Inspector set the class to "BoxView" .

In the Attributes Inspector set borderColor , borderWidth , and cornerRadius .

Download Sample Project on GitHub. MIT License.