[英]how to show the orginal color of the button in a toolbar
我有一個應用程序,其中我正在創建一個工具欄以瀏覽Web視圖。除按鈕的顏色外,其他所有東西都正常運行。當我不啟用按鈕時,它顯示的顏色與按鈕的顏色相同工具欄。當我啟用它時,它顯示為白色。但是我需要按原樣顯示按鈕。這就是我的操作方式,
[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];
`
我如何獲取啟用按鈕的按鈕的原色=否;有人可以幫助我嗎
我已經提出了一個解決方案,很高興與所有面臨相同問題的人分享。
[[UIBarButtonItem appearance] setTintColor:[UIColor redColor]];
這樣,您可以給任何顏色的按鈕。
以下鏈接提供了完整的代碼,用於更改UIToolBar中的UIButton的顏色http://charles.lescampeurs.org/2011/02/10/tint-color-uibutton-and-uibarbuttonitem
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.