Button color in Navigation bar - iPhone

前端 未结 6 1346
独厮守ぢ
独厮守ぢ 2020-12-09 20:53

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:

相关标签:
6条回答
  • 2020-12-09 21:25

    It is not possible without your custom image.

    0 讨论(0)
  • 2020-12-09 21:45

    From iOS 5.0 and on you can use:

        [[UINavigationBar appearance] setTintColor:[UIColor yellowColor]];
    
    0 讨论(0)
  • 2020-12-09 21:45

    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];
    
    0 讨论(0)
  • 2020-12-09 21:48
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor colorWithRed:0.1f green:0.66f blue:0.26f alpha:0.7];
    
    0 讨论(0)
  • 2020-12-09 21:51
     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];
    
    0 讨论(0)
  • 2020-12-09 21:52

    when you set your image of the button in navigation bar, you may want to set UIImageRenderingModeAlwaysOriginal for it:

    [addButton setImage:[[[UIImage imageNamed:@"bg_table.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] retain]];
    

    here is the reference.

    0 讨论(0)
提交回复
热议问题