I've been playing with the IBInspectable/IBDesignable like in this article: http://nshipster.com/ibinspectable-ibdesignable/.
It shows how you can make an extension to add extra editing options in storyboard. The problem however is that you can't see these changes reflected in the preview. For this you need to subclass, use IBDesignable
and do the didset{}
stuff.
The problem with this is that you need to make a subclass of every stock UIView
subclass. So a subclass of UILabel
, UITextField
and so on. Every time you have to copy/paste the regular UIView
stuff like borders and corner radius.
I don't believe Swift supports multiple inheritance, which would have made this much easier.
Let's say your IBDesignable
subclass of UIView
is called IBView
. Is there a way to make e.g. UILabel
be a subclass of IBView
instead of UIView
?
In the end I'm looking if there is a way to make IBDesignable
less tedious.
Like you, I'm trying to find a better solution to work with IBDesignable.
What I did to avoid repeat the same code:
Check this code:
I hope it helps you!