Simple settings of IOS tabbarviewcontroll

Source: Internet
Author: User

One is to set tabbarviewcontroller in appdelegate and then use self. View controllers add another view con
The two types are inherited from the tabbarviewcontroller class, and then the VC class is added to it,
A simple tabbar background color, as well as the items font and image, is to draw a tabbar background image with a length, width, and height of 320 and a length of 49, divide it into several pieces and PS the items content and images. In this way, you can set the tabbar background,
[Self. tabbar setbackgroundimage: [uiimage imagenamed: @ "tab_bg.png"];
In addition, when you click items, the animation is generated. The simple method is to set an image, add it to the tabbar, and then add it, button, and loop through a button to load the tabbar, use the button click event to change the Image Location
Code

Uiimageview * _ selectedtag = [[[uiimageview alloc] initwithimage: [uiimage imagenamed: @ "tabbar_tag.png"] autorelease];
[_ Selectedtag setframe: cgrectmake (31, 15, 20, 19)]; [self. tabbar addsubview: _ selectedtag]; for (INT I = 0; I <5; I ++) {uibutton * tabbutton = [[uibutton alloc] initwithframe: cgrectmake (20 + I * 56, 0, 56, 49)] autorelease]; tabbutton. tag = I; [tabbutton addtarget: Self
Action: @ selector (tabbuttontapped :) forcontrolevents: uicontroleventtouchupinside]; [self. tabbar addsubview: tabbutton];}
Add them to the tabbar and call the method.
-(Void) tabbuttontapped :( uibutton *) sender {
Self. selectedindex = sender. Tag ;//
// Click the image movement event and the tabbar event.
// If (self. selectedindex = channlemore) {// uinavigationcontroller * morenav = (uinavigationcontroller *) self. selectedviewcontroller; // [morenav poptorootviewcontrolleranimated: No]; //} [uiview animatewithduration :. 2 animations: ^ {[_ selectedtag setframe: cgrectmake (31
+ 60 * sender. Tag,-15, 20, 19)] ;}] ;}
The above is the simple use of tabbar,
If you do not need an image to replace the settings of the control, you can set the itmes of tabbar as follows:
[[Self. tabbar. Items objectatindex: 0] settitle: @ "Homepage"]
You can also set the background, image, and font,
Similarly, uinavigationcontroller can be implemented in the same way, that is, hiding uinavigationcontroller. navigationbarhidden = yes; and then creating the navigation bar by yourself,
The method is similar to that of tabbar,
The above is the simple use of the method

Related Article

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.