@IBInspectable coming back nil in custom button class

Viewed 555

I followed this tutorial in order to create reusable UI components for interface builder. I have followed the article exactly and the results I'm getting are the same as explained in the article.

The issue I'm not having is that I have added an @IBInspectable property called style to the class, which shows up fine in the properties inspector of interface builder, however no matter what I do it always comes back nil in both the Setup() and loadViewFromNib() methods of the MyButton class.

Being new to Interface Builder custom components, I am starting to wonder whether the method followed in the article breaks @IBInspectable properties, as I have used them successfully past by using custom UIButton classes without adding the extra XIB component.

Any help would be much appreciated.

    @IBDesignable
    class MyButton: UIButton {
        @IBOutlet weak var view: UIButton!
        @IBInspectable var style: String!
...
1 Answers
Related