UINavigationBar background color not the exact UIColor I set it to

前端 未结 12 1581
天命终不由人
天命终不由人 2020-12-14 00:16

Please look at the screenshot below.

I set all the tint colors from the same UIColor object for the UINavigationBar, search bar and toolbar at the bottom. But for so

12条回答
  •  一生所求
    2020-12-14 00:34

    It differs because of default UINavigationBar blur effect. I can suggest to set 2px width stretchable background image with your color. Something like this:

        UIImage *image = [UIImage imageNamed:@"yourBlueImage"];
        image = [image stretchableImageWithLeftCapWidth:image.size.width / 2.0f topCapHeight:0.0f];
        [yourNavBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
    

    It's like a trick, because when you set custom backgroundImage blur effect will be disabled and you'll get exact color.

提交回复
热议问题