Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8076649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:18:27+00:00 2026-06-05T15:18:27+00:00

I’m styling my UINavigationBar with UIAppearance . I want all the back buttons to

  • 0

I’m styling my UINavigationBar with UIAppearance. I want all the back buttons to have gray text and all my rightBarButtonItems to have green text (colors are hypothetical). Since both buttons are UIBarButtonItems by default, UIAppearance would not be able to differentiate the two. So I decided to subclass a UIBarButtonItem, calling it ActionBarButtonItem. I use this new subclass anywhere I need a rightBarButtonItem.

rightBarButtonItem

UIBarButtonItem* done = [[ActionBarButtonItem alloc] 
    initWithTitle:@"Done"
    style:UIBarButtonItemStyleDone
    target:self 
    action:@selector(onDonePress)];
self.navigationItem.rightBarButtonItem = done;
[done release];

UIAppearance

NSDictionary* buttonStyle = [NSDictionary 
    dictionaryWithObjects:[NSArray 
        arrayWithObjects:
            [UIColor grayColor],
            , nil
        ]
        forKeys:[NSArray
            arrayWithObjects:
                UITextAttributeTextColor,
                nil
        ]
];

NSDictionary* actionStyle = [NSDictionary 
    dictionaryWithObjects:[NSArray 
        arrayWithObjects:
            [UIColor greenColor],
            nil
        ]
        forKeys:[NSArray
            arrayWithObjects:
                UITextAttributeTextColor,
                nil
        ]
]; 

[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationController class], nil] 
    setTitleTextAttributes:buttonStyle
    forState:UIControlStateNormal
];

[[ActionBarButtonItem appearanceWhenContainedIn:[UINavigationController class], nil]
    setTitleTextAttributes:actionStyle
    forState:UIControlStateNormal
];

Theoretically, the gray text would be applied for all UIBarButtonItems. Then I override that gray text with green text for ActionBarButtonItems only. The final result is not as expected. For unknown reasons, every UIBarButtonItem gets green text. Why?

enter image description hereenter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:18:28+00:00Added an answer on June 5, 2026 at 3:18 pm

    You are sub classing UIBarButton so my initial thought here is that when you call appearanceWhenContainedIn on ActionBarButtonItem the result is a call on the super classes appearanceWhenContainedIn and therefore this is why this is happening. It is not ideal but you could change the appearance of the left and right items on the view did load or view will appear in each view.

    NSDictionary* buttonStyle = [NSDictionary 
                                     dictionaryWithObjects:[NSArray 
                                                            arrayWithObjects:
                                                            [UIColor blueColor],nil]
                                     forKeys:[NSArray
                                              arrayWithObjects:
                                              UITextAttributeTextColor,
                                              nil
                                              ]
                                     ];
    
    NSDictionary* actionStyle = [NSDictionary 
                                 dictionaryWithObjects:[NSArray 
                                                        arrayWithObjects:
                                                        [UIColor greenColor],
                                                        nil
                                                        ]
                                 forKeys:[NSArray
                                          arrayWithObjects:
                                          UITextAttributeTextColor,
                                          nil
                                          ]
                                 ]; 
    
    
    
    [self.navigationItem.leftBarButtonItem setTitleTextAttributes:buttonStyle forState:UIControlStateNormal];
    [self.navigationItem.rightBarButtonItem setTitleTextAttributes:actionStyle forState:UIControlStateNormal];
    

    You may also choose to put this somewhere convent like your app delegate so you can access it more simply with [[UIApplication sharedApplication].delegate setBarButtonColors].
    Another alternative could be a category on UINavigationBar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have a French site that I want to parse, but am running into
I have a reasonable size flat file database of text documents mostly saved in
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.