【问题标题】:UIToolbar tintColor and barTintColor issuesUIToolbar tintColor 和 barTintColor 问题
【发布时间】:2013-10-30 23:05:02
【问题描述】:

我有这样的代码:

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];

为什么工具栏子视图的颜色与我的视图不同?视图显示为黑色,工具栏显示为浅灰色?是否有模糊或其他原因?

【问题讨论】:

  • 我想制作一个高度为 64.0 的工具栏,其 tintColor 与我的导航栏相同。
  • 默认情况下,-barStyle for UIToolBarTranslucent light in iOS7。您可以将其更改为Translucent dark

标签: ios uiview ios7 uitoolbar tintcolor


【解决方案1】:

试试这个代码,它会帮助你,

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;

根据您的要求更改tintColoralpha

【讨论】:

    【解决方案2】:

    UINavigationBar 的某些属性的行为已从 iOS 7 更改。这件事我已经在我的Answer里解释过了。

    看看iOS 6iOS 7酒吧风格


    你可以在这里注意两点:

    1. 您可以将条形样式更改为translucent dark,而不是translucent light(默认)。
    2. 您可以将translucent 属性从YES(默认)更改为NO

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多