Customizing the menu bar (Uibarviewcontroller)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.