[IOS development-UITabBarController] UINavigationController settings on UITabBarController, uitabbarcontroller
Custom navigation bar
To ensure that the navigation bar of the project remains effective, the style of the navigation bar is usually the same.
① Customize a NavigationController class, inheriting from the UINavigationController class
② Change the class attribute of UINavigationController under all UITabBarController to custom class form
③ Obtain the appearance object in the navigation bar and set the topic of the navigation bar.
UINavigationBar *navBar = [UINavigationBar appearance];
④ Navigation bar background
// Set the navigation bar background-(void) setBackgroundImage :( UIImage *) backgroundImage forBarMetrics :( UIBarMetrics) barMetrics;
⑤ Set the title
@ Property (nonatomic, copy) NSDictionary * titleTextAttributes; // key used in the dictionary in UIStringDrawing. h // The key of the latest version is in NSAttributedString. h of the UIKit framework.
Custom navigation bar buttons
UIBarButtonItem *item = [UIBarButtonItem appearance];
Image Type of the iOS6 navigation bar background
Non-retina: 320x44 px
Retina: 640x88 px
Image Type of the iOS7 navigation bar background
Retina: 640x128 px
Custom NavigationController
Step for customizing the navigation Controller: Create a class that inherits from UINavigationController
Value of custom navigation controllers
Rewrite the push method to intercept all subcontrollers pushed into the stack and perform some unified processing.
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated;
Rewrite the pop method to intercept the output stack of all sub-controllers.
- (UIViewController *)popViewControllerAnimated:(BOOL)animated;
To hide the UITabBar when pushing the controller, you need to make the following settings:
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{ viewController.hidesBottomBarWhenPushed = YES; [super pushViewController:viewController animated:animated];}
Differences between initailize and load methods
Initailize and load are both Class Methods
When a class is loaded into the memory, the load method is called once (this class is not available at the time)
When this class is used for the first time, the initailize method is called.