I read this post but I can’t get it working: Change Background Color…
I like to create a base UIView class for all my view customization like background pattern, color of the buttons, color of the tab bar etc.
This is what I’ve tried:
- Created a new
Single View Application - Customized the view in
UIViewControllermethod-viewDidLoad - Created a new subclass of that
UIViewController - In IB I created a new
UIViewControllerobject - In IB (Identity Insp.) I set the
UIViewControllerclass to the subclass I created earlier
Is this not the proper way to do this?
I was thinking that the new created UIViewController class will inherit all
customizations from my first UIViewController class since I subclassed that one.
Second question is how can I use a base class for certain objects instead of a whole view?
For example how do I let all UIButtons in my App inherit all the behavior I have defined in just one single class?
Hope you can help.
Happy Easter for all.
I believe you want to customize your view, but exactly how and when is not clear to me.. so I will just give the common method which will give you the general idea of how to do it..
First create a subclass of
UIViewsayBaseViewwith properties to be customized, now in the viewDidLoad methods of your viewController create an object ofBaseViewand customize this object as you like.. once this is done just set the self.view property of your viewController to this newly createdBaseViewobject and then release theBaseViewobject..hoping this helps you somewhat…
EDIT:
based on the comments ..
First create a
BaseViewControllerclass which subclassesUIViewController… in theviewDidLoadof this class customize your view usingself.viewSecond now the viewControllers which you want to use in your
tabControllershould subclass thisBaseViewController… just don’t forget the[super viewDidLoad];is called in theviewDidLoadof this viewcontroller.this is the best I have to offer.. 🙂 let me know if it works for you.