I had an application in which i am creating a toolbar to navigate through the web view .everything is working fine,except for the color of the button.when i am not enabling the button it is showing as the same color as the tint color of the toolbar.and when i enable it it is showing as white.but i need to present the button as it is.here is how i am doing it ,`
[self.navigationController setToolbarHidden:NO animated:YES];
self.navigationController.toolbar.barStyle = UIBarStyleBlackTranslucent;
self.navigationController.toolbar.tintColor=[UIColor colorWithRed:215/255.0 green:215/255.0 blue:215/255.0 alpha:1.0];
buttonGoBack = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back_icon.png"] style:UIBarButtonItemStylePlain target:self action:@selector(backButtonTouchUp:)];
UIBarButtonItem *fixedSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
fixedSpace.width = 30;
buttonGoForward = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"forward_icon.png"] style:UIBarButtonItemStylePlain target:self action:@selector(forwardButtonTouchUp:)];
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
buttonAction = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(buttonActionTouchUp:)];
UIBarButtonItem *buttonContainer = [[UIBarButtonItem alloc] initWithCustomView:containerView];
[containerView release];
NSMutableArray *toolBarButtons = [[NSMutableArray alloc] init];
[toolBarButtons addObject:buttonGoBack];
[toolBarButtons addObject:fixedSpace];
[toolBarButtons addObject:buttonGoForward];
[toolBarButtons addObject:flexibleSpace];
[toolBarButtons addObject:buttonContainer];
[toolBarButtons addObject:flexibleSpace];
[toolBarButtons addObject:buttonAction];
// Set buttons to tool bar
[self.navigationController.toolbar setItems:toolBarButtons animated:YES];
`
how can i get the orginal color of the button for button enabled=NO;Can anybody help me
I had made out a solution ,happy to share with all if anybody facing the same problem.
[[UIBarButtonItem appearance] setTintColor:[UIColor redColor]];
In this way you can give any color the barbuttons.
以下链接提供了完整的代码,用于更改UIToolBar中的UIButton的颜色http://charles.lescampeurs.org/2011/02/10/tint-color-uibutton-and-uibarbuttonitem
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.