I have created a custom UIView
and I would like to initialize
it with custom parameters from the UIStoryboard
. Basically I have added a UIView
in the UIStoryboard
and I have changed the class to my custom UIView
.
In my custom UIView
class I'm using the initWithCoder
method to initialize
it but I would like to use the provided NSCoder
to get some configuration parameters from the UIStoryboard
, is this possible or is there another way to pass parameters from the UIStoryboard
to my custom UIView
?
Thanks!!
Apparently is not possible to add parameters to NSCoder using the initwithCoder:
Initializing a view with custom initWithCoder
I have found a workaround to solve the problem, simply using the User Defined Runtime Attributes doing the following:
1) Add the custom properties in the storyboard in the "User Defined Runtime Attributes".
2) Add the same properties to my custom class.
3) Use the properties to customize the UIView in the awakeFromNib method.
With this solution, I'm able to initialize my custom UIView from the storyboard and just use it from my controller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With