条形图将调整您的颜色值。
首选方法,仅对于RGB> = 40,将产生最大的模糊
您可以使用此计算器并在屏幕上显示时输入想要的颜色,它将告诉您如何设置barTintColor的颜色,因此当Apple对其进行调整时,它将按预期显示
https://www.transpire.com/insights/blog/bar-color-calculator/
编辑:请注意,这些计算是针对白色背景和较浅的颜色(超过40的rgb,如果您需要更暗,则需要像其他人一样添加背景层-尽管这会减少条形的模糊)
深入指南:https : //www.transpire.com/insights/blog/custom-ui-navigationbar-colors-ios7/
片段:
@interface UnderlayNavigationBar : UINavigationBar
@end
。
@interface UnderlayNavigationBar ()
{
UIView* _underlayView;
}
- (UIView*) underlayView;
@end
@implementation UnderlayNavigationBar
- (void) didAddSubview:(UIView *)subview
{
[super didAddSubview:subview];
if(subview != _underlayView)
{
UIView* underlayView = self.underlayView;
[underlayView removeFromSuperview];
[self insertSubview:underlayView atIndex:1];
}
}
- (UIView*) underlayView
{
if(_underlayView == nil)
{
const CGFloat statusBarHeight = 20;
const CGSize selfSize = self.frame.size;
_underlayView = [[UIView alloc] initWithFrame:CGRectMake(0, -statusBarHeight, selfSize.width, selfSize.height + statusBarHeight)];
[_underlayView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[_underlayView setBackgroundColor:[UIColor colorWithRed:0.0f green:0.34f blue:0.62f alpha:1.0f]];
[_underlayView setAlpha:0.36f];
[_underlayView setUserInteractionEnabled:NO];
}
return _underlayView;
}
@end
。
UIViewController* rootViewController = ...;
UINavigationController* navigationController = [[UINavigationController alloc] initWithNavigationBarClass:[UnderlayNavigationBar class] toolbarClass:nil];
[navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:0.0f green:0.0f blue:90.0f/255.0f alpha:1]];
[navigationController setViewControllers:@[rootViewController]];