2013-10-21 37 views
0

UIToolBar为什么UIToolBar未在模态视图中设置颜色,具有浅灰色的默认背景颜色?更改UIToolbar的颜色

这是搞乱我的barTintColor和改变背景也没有帮助。

我该如何解决这个问题?

+0

? –

+0

是的,这是正确的。我看到toolbar.barStyle,但导航栏上的黑色色彩与工具栏不匹配。工具栏的默认颜色是什么? – cdub

+0

除非将半透明属性设置为NO,否则默认情况下色调颜色将变为半透明。 –

回答

2

UIToolbar也具有tintColor属性,就像UINavigationBar一样。您应该能够设置一个其他:

所以,如果你想在UINavigationBar的色调颜色设置为UIToolBar色调的颜色那么就

yourtoolbar.tintColor = yournavbar.tintColor; 

在您的实现文件的末尾只写这个。

UIToolbar用颜色:

@implementation UIToolbar (UIToolbarCategory) 
- (void)drawRect:(CGRect)rect { 
    UIColor *color = [UIColor WhiteColor]; 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    CGContextSetFillColor(context, CGColorGetComponents([color CGColor])); 
    CGContextFillRect(context, rect); 
} 
@end 

希望它有助于..

要设置工具栏色调颜色相同的导航栏着色颜色
+0

问题是uitoolbar默认是灰色而不是白色。我如何使它变成白色? – cdub

+0

或者摆脱默认颜色? – cdub

+0

看看你是否希望你的工具栏tintcolor与导航栏相同,那么上面的答案将工作..否则将更新我的答案 –