UIToolbar tintColor and barTintColor issues
Asked Answered
S

2

8

I have code like so:

UIView *colorView = [[UIView alloc] init];
colorView.frame = CGRectMake(0.0, 0.0, self.view.frame.size.width, 64.0);
colorView.backgroundColor = [UIColor blackColor];
//colorView.tintColor = [UIColor blackColor];

UIToolbar *toolbar = [[UIToolbar alloc] init];
toolbar.frame = CGRectMake(0.0, 0.0, self.view.frame.size.width, 44.0);

self.view addSubview:colorView];
[self.view addSubview:toolbar];

Why does the toolbar subview have a different color then my view? The view appears black and the toolbar appears light gray? Is there a blur or something causing this?

Shrubbery answered 22/10, 2013 at 7:33 Comment(2)
I want to make a 64.0 height toolbar that has the same tintColor as my navigation bar.Shrubbery
By default, -barStyle for UIToolBar is Translucent light in iOS7. You can change it to Translucent dark.Molton
M
9

Behavior from some of the properties of UINavigationBar has changed from iOS 7. I have already explained this thing in my Answer.

Take a look at the Bar style for iOS 6 and iOS 7 :

enter image description here


You can note two points here :

  1. You can change the Bar style to translucent dark instead of translucent light (default).
  2. You can change the translucent property to NO from YES (default).
Molton answered 22/10, 2013 at 8:5 Comment(0)
L
2

Try this code, it will help you,

UIToolbar *toolbar = [[UIToolbar alloc] init];
toolbar.frame = CGRectMake(0.0, 0.0, self.view.frame.size.width, 44.0);
toolbar.barStyle = UIBarStyleBlackTranslucent;
toolbar.tintColor = [UIColor blackColor];
toolbar.alpha = 0.0;

Change the tintColor and alpha based on your requirement.

Leonelleonelle answered 22/10, 2013 at 8:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.