Extensions May not contain Stored properties

You can override the setter/getter so that it isn’t a stored property and just forwards the set/get to the layer.

extension UIButton {
    @IBInspectable var borderWidth : CGFloat {
        set {
            layer.borderWidth = newValue
        }

        get {
            return layer.borderWidth
        }
    }
}

Leave a Comment