简体   繁体   English

获取导航栏的真实颜色

[英]Get the real color of the navigation bar

For my app on iPhone XI need to create a footer. 对于我在iPhone XI上的应用,需要创建一个页脚。 No problem here. 没问题

BUT I need to put the same color as the navigation bar . 但是我需要把颜色和导航栏的颜色一样

The color of the navigationBar is set on barTintColor and cannot be changed. navigationBar的颜色在barTintColor上设置,无法更改。

The app builded, a UIVisualEffect is set automatically on the navigationBar and the color change : it's lighter. 内置应用程序后,会自动在navigationBar上设置UIVisualEffect并更改颜色:它更轻。

How can I get the color shown of the navigation bar? 如何获得导航栏显示的颜色?

What I tried but didn't work : 我试过但没用的东西:

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

**The code for the navigation bar : ** **导航栏代码:**

self.navigationController.navigationBar.barTintColor = tintColor;

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

**The code for the footer ** **页脚代码**

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

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

Screenshot of the problem : 问题的屏幕截图:

Screenshot 屏幕截图

Or what about autoresizing mask ? 或自动调整蒙版大小呢?

   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