Talk is cheap show me the design

Nikhil Manapure
The Swift Blog
Published in
2 min readJan 10, 2017

There are many ways provided by apple to render custom views on storyboard which makes designing easy and simple. WYSIWYG has truly come to storyboards due to below guys.

  1. Runtime attributes —

Our old friend which is good enough to do everything what other guys can do, but doesn’t give dynamic way to add things & also no type checking 😞.

2. IBInspectable —

This is quite simple and will generate below results.
Find this in attributes inspector

Now whatever you set in this text will be set to label present in your custom view.

3. IBDesignable —

Efforts
Result

@IBDesignable prefix or the (or the IB_DESIGNABLE macro in Objective-C) let the interface builder know that this view should be rendered to storyboard too.

4. prepareForInterfaceBuilder() —

As the name suggests, you can set up your view exclusively for storyboard rendering. This method works with @IBDesignable and lets us do stuff on view right before it is rendered.

5. TARGET_INTERFACE_BUILDER —

This lets us to embed the prepareForInterfaceBuilder code directly in draw(_ rect: CGRect) or in layoutSubviews() .

Using all of these guys in combination, we can optimize our storyboard designing but do use them wisely.

“Talk is cheap. Show me the code.”
― Linus Torvalds

--

--