Oc-tabbar the selected text changes color

Source: Internet
Author: User

The system is blue by default. But when Tabbaritem's selected icon is changed to Gray, we also want to change the text to Gray. This is the time to use it.

Settitletextattributes "method.

The following method can be found in the parent class "Uibaritem" Class of the "Uitabbaritem" class:

/* Specify the font, text color, and shadow properties for the title in the text attributes dictionary, using the Keys found in NSAttributedString.h.

*/

-(void) Settitletextattributes: (Nullable nsdictionary<nsstring *,ID> *) attributes Forstate :(uicontrolstate) state Ns_available_ios (5_0) ui_appearance_selector;

This method is used to change the color of the text. You can find the Keys in the "NSAttributedString.h" class.

    //defaultNsmutabledictionary *attrs =[Nsmutabledictionary dictionary]; Attrs[nsfontattributename]= [Uifont systemfontofsize: A]; Attrs[nsforegroundcolorattributename]=[Uicolor Graycolor];        [Essencevc.tabbaritem settitletextattributes:attrs Forstate:uicontrolstatenormal]; //selectedNsmutabledictionary *attrselected =[Nsmutabledictionary dictionary]; Attrselected[nsfontattributename]= [Uifont systemfontofsize: A]; Attrselected[nsforegroundcolorattributename]=[Uicolor Darkgraycolor]; [Essencevc.tabbaritem settitletextattributes:attrselected forstate:uicontrolstatenormal];

Oc-tabbar the selected text changes color

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.