Entertainment Big Coffee Project-summary

Source: Internet
Author: User

One, basic configuration

1. The first need to match some skeleton, this project uses the root controller when the Tabbarcontroller is the root controller.

First modification point:

image = [Image imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];

This is to keep the picture as before, without being changed to blue by the system.

The above is the code, but also through Assets.xcassets is specifically to manage the picture, click to modify an image of a property can be changed to Rende as to original image can be

Second point of modification:

Uiviewcontroller *VC = [[Uiviewcontroller alloc]init];

Nsmutabledictionary *dict = [Nsmutabledictionary dictionary];

Dict[nsfontattributename] = [Uifont systemfontofsize:13];

Dict[nsforegroundcolorattributename] = [Uicolor whitecolor];

[Vc.tabbaritem settitletextattributes:dict Forstate:uicontrolstatenormal];

The above is to modify the Tabbaritem in the controller under the text color when clicked, not by the system changes, of course, there is a better way.

Modify property changes for text in multiple item by appearance properties in Uitabbaritem

Nsmutabledictionary *attrs = [nsmutabledictionary dictionary];    Attrs[nsfontattributename] = [Uifont systemfontofsize:12];    Attrs[nsforegroundcolorattributename] = [Uicolor graycolor];        Nsmutabledictionary *selectedattrs = [nsmutabledictionary dictionary];    Selectedattrs[nsfontattributename] = Attrs[nsfontattributename];    Selectedattrs[nsforegroundcolorattributename] = [Uicolor darkgraycolor];            Uitabbaritem *item = [Uitabbaritem appearance];    [item Settitletextattributes:attrs Forstate:uicontrolstatenormal];        [item Settitletextattributes:selectedattrs forstate:uicontrolstateselected];

This can also be done through multiple sub-controllers, only need to set one time to meet all of their property changes, of course, there is a need for the method behind

Ui_appearance_selector to use Appearance unified setup

2. Customizing the Sub-controller

// establish a method to initialize the child controller -(void) SETUPCHILDVC: (Uiviewcontroller *) VC title: (NSString *) title Image: (NSString *) Image SelectedImage: (NSString *) selectedimage{
= title; = [UIImage imagenamed:image]; = [UIImage imagenamed:selectedimage]; // Package A navigation controller, add a Tabbarcontroller controller for the navigation controller Zwnavigationcontroller *NAVC = [[Zwnavigationcontroller ALLOC]INITWITHROOTVIEWCONTROLLER:VC]; [Self ADDCHILDVIEWCONTROLLER:NAVC];}

This makes it easy to simplify the amount of code in Viewdidload and also reduces code redundancy.

Project: If you want to get a similar Tabbar controller, you have to customize

2.2 Custom Tabbar

// Replace Tabbar     //     Self.tabbar = [[Xmgtabbar alloc] init]; The Tabar property is a read-only property, so you can replace the system    KVC by TabBar [Self Setvalue:[[zwtabbar alloc] init] Forkeypath:@ "tabBar"];

Modify the _tabbar to modify the properties of the Tabbar by KVC Way

Then change the style of the desired Tabbar by Layoutsubviews method

- (void) layoutsubviews{[Super Layoutsubviews]; CGFloat width=Self.width; CGFloat height=Self.height; //set the frame of the Publish buttonSelf.publishButton.bounds = CGRectMake (0,0, Self.publishButton.currentBackgroundImage.size.width,        Self.publishButton.currentBackgroundImage.size.height); Self.publishButton.center= Cgpointmake (Width *0.5, Height *0.5); //set the other Uitabbarbutton frameCGFloat buttony =0; CGFloat buttonw= width/5; CGFloat Buttonh=height; Nsinteger Index=0;  for(UIView *buttoninchself.subviews) {if(! [Button Iskindofclass:[uicontrolclass]] || button = = Self.publishbutton)Continue; //calculate the X value of a buttonCGFloat Buttonx = buttonw * (Index >1)? (Index +1): index); Button.frame=CGRectMake (Buttonx, Buttony, Buttonw, Buttonh); //Add indexindex++; }}

The above code will give you the style of the above image.

Entertainment Big Coffee Project-summary

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.