I have the following code:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
webControlsToolbar_ = [[UIToolbar alloc] init];
[self.webControlsToolbar_ setTintColor:[UIColor colorWithRed:246.0/255.0 green:246.0/255.0 blue:246.0/255.0 alpha:1]];
Any idea why the color is still solid black? In my view did load I added the toolbar:
self.webControlsToolbar_.frame = CGRectMake(0, self.view.frameHeight - self.webControlsToolbar_.frameHeight + 1.0, self.view.frameWidth, self.webControlsToolbar_.frameHeight);
[self.view addSubview:self.webControlsToolbar_];
I've run into a similar problem before. I resolved it by setting the tint color immediately before showing the toolbar in code. See if that works for you.
我发现更容易按照实用工具栏的要求完全设置按钮,标签等的背景颜色,然后创建一个名为say,myOutlet的插座,并执行以下操作:
[self.webControlsToolbar_ setTintColor:myOutlet.backgroundColor];
The issue is at the line
self.webControlsToolbar_.frame = CGRectMake(0, self.view.frameHeight - self.webControlsToolbar_.frameHeight + 1.0, self.view.frameWidth, self.webControlsToolbar_.frameHeight);
Try to NSLog
a self.webControlsToolbar_.frameHeight
property and you should see that is zero after [UIToolBar new];
Use a constant height instead.
You have to change this attribute in the viewDidLoad
method:
-(void)viewDidLoad{
[super viewDidLoad];
//Custom initialization
[self.webControlsToolbar_ setTintColor:[UIColor colorWithRed:246.0/255.0 green:246.0/255.0 blue:246.0/255.0 alpha:1]];
}
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.