Common settings for Uitabbar in iOS

Source: Internet
Author: User

Uitabbar is very common, it can achieve multiple pages of fast switching, and looks simple and practical.

Suppose I have several initialized Viewcontroller, and then I need to add them to the Tabbarcontroller and set it to the root view

Nsarray *views = [[Nsarray alloc] initwithobjects:test, time, Test1, Test2, Test3, 

test4, nil];  
      
Uitabbarcontroller *TBC = [[Uitabbarcontroller alloc] init];  
Tbc.viewcontrollers = views;  
      
Self.window.rootViewController = TBC;

After you set it up, look at the Tabbar's effect chart.

The item for each view here has a few attributes, titles title, image Image, and the circle icon on the right of time that shows Badgevalue. You can set its Tabbaritem property when you overwrite the view's initialization method.

- 

(ID) initwithnibname: (NSString *) Nibnameornil Bundle: (NSBundle *) Nibbundleornil  
{  
    self = [super Initwithnibname:nibnameornil Bundle:nibbundleornil];  
    if (self) {          
        self.tabBarItem.title = @ "Time";  
        Self.tabBarItem.image = [UIImage imagenamed:@ "Time.png"];  
        Self.tabBarItem.badgeValue = [NSString stringwithformat:@ '%d ', 3];  
    }  
    return self;  
}

Again look at the far right of the effect chart, it is more, this is because Tabbar defaults to display up to 5 item, superfluous will automatically add to more, click More will pop up a navigationbar, there is an edit button

Click Edit

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

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.