I’m struggling with some basics in my storyboard-based iOS Application.
I like to load some UIView’s which are builded up in NIB-Files (xib). If I load the View, the initWithCoder-method will be called.
Now I like to load “green” Views; I read, that I’m able to put some other initializations in the initWithCoder – but only “new” objects and nothing, that regarding the View itself, like self.backgroundColor in cause of memory (maybe the object isn’t complete initialized at that point).
Where is the best place to add some stuff, like setBackgroundColor, setCornerRadius in the view-Class itself?
I’m doing it like this:
Also , the view , in the nib file is set as a
MyCustomViewinstead ofUIView.After these 2 lines you can set any values that you want. Be aware though , if you set the frame for super for example , it will be overwritten by the values in the xib file. So better set everything AFTER loading the nib , not before.
As far as I know , there are no callbacks for
UIViewloading asviewDidLoadis forUIViewController.Hope this helps.
Cheers!
EDIT:
You can do something like this:
And then just use that
initWithInfo: Body:method.