Get the right color in iOS7 translucent navigation bar

后端 未结 20 1203
囚心锁ツ
囚心锁ツ 2020-11-28 00:59

How can I get the right coloring for my translucent navigation bars in iOS 7? The navigation bar just adjusts the given color to a much brighter one. Changing brightness or

20条回答
  •  迷失自我
    2020-11-28 01:21

    This should work:

    UIColor *barColour = [UIColor colorWithRed:0.13f green:0.14f blue:0.15f alpha:1.00f];
    
    UIView *colourView = [[UIView alloc] initWithFrame:CGRectMake(0.f, -20.f, 320.f, 64.f)];
    colourView.opaque = NO;
    colourView.alpha = .7f;
    colourView.backgroundColor = barColour;
    
    self.navigationBar.barTintColor = barColour;
    
    [self.navigationBar.layer insertSublayer:colourView.layer atIndex:1];
    

    Taken from here

提交回复
热议问题