Button color in Navigation bar - iPhone

17,648

Solution 1

It is not possible without your custom image.

Solution 2

self.navigationItem.rightBarButtonItem.tintColor = [UIColor colorWithRed:0.1f green:0.66f blue:0.26f alpha:0.7];

Solution 3

From iOS 5.0 and on you can use:

    [[UINavigationBar appearance] setTintColor:[UIColor yellowColor]];

Solution 4

 UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
 [button setBackgroundImage:[UIImage imageNamed:@"button_main.png"]
                                       forState:UIControlStateNormal];
 [button addTarget:self action:@selector(GotoSettings)
              forControlEvents:UIControlEventTouchUpInside];
 button.frame = CGRectMake(x, y, x1, x2);

 UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:menu];
 self.navigationItem.rightBarButtonItem = menuButton;

 [button release];
 [menuButton release];

Solution 5

Actually it's possible without using image for buttons.

viewController.navigationController.navigationBar.tintColor = 
    [UIColor colorWithRed:0.16f green:0.36f blue:0.46 alpha:0.8];
Share:
17,648

Related videos on Youtube

Mladen
Author by

Mladen

Updated on June 04, 2022

Comments

  • Mladen
    Mladen almost 2 years

    How do you to set the tint of this yellow button to be gray? I have tried adding an image, but have had no luck.

    Here is the screenshot:

    alt text

    Here is my current code:

    - (id)initWithStyle:(UITableViewStyle)style {
        if (self = [super initWithStyle:style]) {
    
            UIBarButtonItem *addButton = [[UIBarButtonItem alloc]
                                          initWithTitle:NSLocalizedString(@"Settings", @"")
                                          style:UIBarButtonItemStyleDone
                                          target:self
                                          action:@selector(GoToSettings)];
            [addButton setImage:[[UIImage imageNamed:@"bg_table.png"] retain]];
    
            self.navigationItem.rightBarButtonItem = addButton;
            self.navigationItem.hidesBackButton = TRUE;
            self.view.backgroundColor = [UIColor blackColor];
        }
        return self;
    }
    
  • Mladen
    Mladen over 14 years
    Is it possible to give it some color, for example gray?
  • jim.huang
    jim.huang almost 13 years
    this changes the color of the navigation bar instead of the buttons.
  • Dan J
    Dan J over 12 years
    ...but you can set the button tint this way, see: stackoverflow.com/questions/8220715/…
  • Hanuman
    Hanuman over 12 years
    reverse it you can change the color of the button or T
  • Hanuman
    Hanuman over 12 years
    may be not related, but the answer helped me. I used it in this way toolbar.tintColor = self.navigationController.navigationBar.tintColor; and later adding the toolbar to navigation controller. In the same way you can change the color of the UIButton!!
  • charliehorse55
    charliehorse55 almost 12 years
    addButton.tintColor = [UIColor grayColor];
  • Navnath Godse
    Navnath Godse almost 11 years
    Working fine, but how to set title to button ?