繁体   English   中英

获取导航栏的真实颜色

[英]Get the real color of the navigation bar

对于我在iPhone XI上的应用,需要创建一个页脚。 没问题

但是我需要把颜色和导航栏的颜色一样

navigationBar的颜色在barTintColor上设置,无法更改。

内置应用程序后,会自动在navigationBar上设置UIVisualEffect并更改颜色:它更轻。

如何获得导航栏显示的颜色?

我试过但没用的东西:

  • footer.backgroundColor = [UIColor myColor]

  • footer.tintColor = [UIColor myColor]

  • footer.tintColor = navigationBar.barTintColor

  • footer.backgroundColor = navigationBar.barTintColor
  • imageView.image = [self.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault]; [footer addSubview: imageView];

  • UIVisualEffect *blurEffect; blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; UIVisualEffectView* visualView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; [self.footer addSubview:visualView];

**导航栏代码:**

self.navigationController.navigationBar.barTintColor = tintColor;

[self.navigationController.navigationBar setTitleTextAttributes:
 [NSDictionary dictionaryWithObjectsAndKeys:
  [UIFont dpBoldFontWithSize:16.8],NSFontAttributeName,
  fontColor,NSForegroundColorAttributeName,
  nil]];
[self.navigationItem setTitle:title];

**页脚代码**

  self.footerView = [[UIView alloc] initWithFrame:CGRectMake(0, kScreenHeight - 35, self.view.width, 35)];

    [self.footerView setBackgroundColor:color];
    [self.view addSubview:self.footerView];

问题的屏幕截图:

屏幕截图

或自动调整蒙版大小呢?

   UIView * footerView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height - 35, self.view.bounds.size.width, 35)];
    footerView.backgroundColor = UIColor.redColor;
    footerView.autoresizingMask = (UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth);
    [self.view addSubview:footerView];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM