在iOS7半透明导航栏中获得正确的颜色

stk*_*stk 70 colors uinavigationbar ios ios7

如何在iOS 7中为我的半透明导航栏获得正确的颜色?导航栏只是将给定的颜色调整为更亮的颜色.改变颜色的亮度或饱和度也无法提供正确的结果.

谁有同样的麻烦?它似乎以某种方式工作,看着Facebook:他们有自己的颜色和半透明的导航栏.

编辑:只是为了说清楚:我需要条形图是半透明的,不透明(有一些阿尔法),不是坚实的!http://en.wikipedia.org/wiki/Transparency_and_translucency

编辑:现在发布到Apple BugReporter

Som*_*Guy 80

条形图将调整您的颜色值.

对于RGB> = 40的优选方法,将给出最大的模糊

您可以使用此计算器并在屏幕上呈现您想要的颜色,它会告诉您如何设置barTintColor的颜色,因此当Apple调整它时,它会显示为预期

http://b2cloud.com.au/how-to-guides/bar-color-calculator-for-ios7-and-ios8/

编辑:请注意,这些计算适用于白色背景,而对于较浅的颜色(rgb超过40,如果您需要更暗,则需要像其他人提到的那样添加背景图层 - 尽管这会减少条纹的模糊)

替代黑暗的底层视图,例如Facebook的深蓝色:(65,96,156) http://img707.imageshack.us/img707/3151/482w.png

深度指南:http://b2cloud.com.au/how-to-guides/custom-uinavigationbar-colors-in-ios7

片段:

@interface UnderlayNavigationBar : UINavigationBar

@end
Run Code Online (Sandbox Code Playgroud)

.

@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
Run Code Online (Sandbox Code Playgroud)

.

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]];
Run Code Online (Sandbox Code Playgroud)

  • 苹果公司的一份文件描述了如何"将酒吧色调颜色与公司或品牌颜色相匹配"https://developer.apple.com/library/ios/qa/qa1808/_index.html (4认同)
  • 谢谢和+1计算器!基本上它的含义是:在任何RGB值中,你都不能拥有比102更暗的颜色.这很糟糕,因为我的管理层不允许我选择任何其他颜色而不是公司(这是RGB 181,27,32),只是因为Apple这样决定.必须有另一种方式,因为Facebook也更暗,它在他们的应用程序的当前版本中具有RGB 65,95,156. (2认同)

mal*_*lex 13

你只需要改变translucent财产

navigationBar.translucent = NO;
Run Code Online (Sandbox Code Playgroud)

它实际上与删除/制作导航栏的透明子视图/子图层相同.