Search code examples
iosxcodecocoacocoa-touchibinspectable

Do I have to hard code the values adjusted by an IBInspectable property?


If I use IBInspectable to adjust the properties and get live updates on Xcode, do I then I have to hard code the values I chose or will the adjusted values be compiled with the final version?

I mean, suppose I use IBInspectable to adjust the border of a view to 10. Should I hardcode that border to 10 or will this value adjusted on a box on Interface Builder be the value that will be compiled for that border?

For a moment the nave IBInspectable got me as something just for inspection...


Solution

  • The values you set in Interface Builder for the IBInspectable properties will be saved in the storyboard and will be set on your object when it is instantiated by the storyboard process. You don't need to set those values through code.

    This is one of the benefits of IBInspectable - you can manipulate and configure your own custom objects in Interface Builder in the same was as you can with the 'in-built' objects such as UILabel and UITextField