1. appdelegage.m file Create Self.window with view (1) initialize window Self.window = [[UIWindow alloc]initwithframe:[uiscreen mainscreen].bounds]; (2) Initialize menu bar Uibarviewcontroller *tabbar = [[Barviewcontroller alloc]init]; (3) Create a view of the window Self.window.rootViewController = tabar; (4) Let the window appear on the first window [Self. Window makeykeyandvisible] * Build a class that inherits Uibarcontroller in the class implementation file (. m) (Create a method)-(void) creatchildcontroller{ //Initialize all the sub-controllers homeviewcontroller *home = [[HomeController alloc]init]; —————— Add a theme to the status bar First method (set theme) Home.title = @ "Home" Second method home.tabaritem.title = @ "Home"; home.navigationItem.title = @ "Home"; ———————— add a background image to the status bar Home.tabBarItem.image = [UIImage imageName: @ "ImageName"]; Click Yes, Change of picture UIImage *selectimage = [UIImage Image: @ "imagenameselect"];home.tabbaritem.selectedimage = [selectimage imagewithrenderingmodealwaysoriginal]; ——————— Add a navigation bar Uinavigationcontroller *navigationcOntroller = [Uinavigationcroller alloc]initwithrootviewcontroller:home]; ————————— added to the menu bar [self addchildviewcontroller:navigationcontroller] *********************** (used after encapsulation) ************* ——— The method used after the encapsulation//title (indicated by the navigation bar and menu bar theme)// imagename (for the menu bar default picture), That is, the initialized picture//Selectedimagename (indicates that the menu bar is printed after a click)//Setup represents a function name//CHILDVC initialized class name -(void)
Setup: (Uiviewcontriller *) CHILDVC title: (NSString *) title Imagname: (nsstring
*) ImageName Selectedimagename: (NSString *) selectedimagename{//Set properties of the controller * * Set the title of the status bar//Set the topic of the status bar Childvc.title = title; ChildVc.tabBarItem.image = [UIImage imagenamed:imagename];
UIImage *selectimage = [UIImage imagenamed:selectimagename];
ChildVc.tabBarItem.selectedImage = [Selectimage imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];
Package a navigation controller
Uinavigationcontroller *nav = [[Uinavigationcontroller ALLOC]INITWITHROOTVIEWCONTROLLER:CHILDVC];
[Self addchildviewcontroller:nav];
Customizing the menu bar (Uibarviewcontroller)