[英]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.