该条将调整您的 colored颜色 值.
Preferred method, for RGB >= 40 only, will give the most blurring
你可以使用这个计算器,在屏幕上渲染时输入你想要的 colored颜色 ,它会告诉你设置条TintColor的 colored颜色 ,这样当Apple调整它时,它就会显示为预期的 colored颜色
https://www.transpire.com/insights/blog/bar-color-calculator/个
编辑:请注意,这些计算是针对白色背景和较浅的 colored颜色 (RGB超过40,如果您需要更深的 colored颜色 ,您将需要添加一个背景层,就像其他人提到的那样-尽管这会减少条形图的模糊)
深度指南: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; // Make this dynamic in your own code...
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]];