对于我在iPhone X上的应用,我需要创建一个页脚。这里没问题。
但我需要使用与导航栏相同的颜色。
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];
问题的屏幕截图:
答案 0 :(得分:0)
或者自动化面膜怎么样?
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];