Matching the color of the transparent navigator

I have a navbar that is set to translucent. I do not want to change this. I set the hue color of the bar on the navigation bar and it looks great. However, the color that I set is not the “true” color that is displayed, since I have a translucent set of “YES”.

I have another view in which there is a background. I would like to set the background color of this view to the same color as the navigation. However, jsut setting the colors does not work. Since the navigator is translucent.

I would like my presentation background to have the same transparency as my colors.

To state again, I do not want to change the transparency or color of the navigator. I want to create a view with the same color and translucency as navigation. However, in iOS you just set the transparency to “YES”, I'm not sure what effect (that is, maybe what alpha) really sets. Is there a formula that I can apply to the view background to fit the navbar?

+4
source share
1 answer

Now I look at this problem and use the level inspector to look at the navigation bar.

As it turned out, the UINavigationBar actually has two color layers in it. One of them is based on your color, and one is a translucent, almost white layer.

Take a look at this screenshot:

enter image description here

There are two layers.

( A) , , UIColor(red: 0.13, green: 0.20, blue: 0.62, alpha: 1.00). .85.

, B, , UIColor(white: 0.97, alpha: 0.5).

, , , - . , , .

: , .

:

, : UINavigationBar UIImageView. , , UIColor(red: 0.0, green: 0.0, blue:0.0, alpha: 0.3).

, UIView, . FilterBar, , , , , UINavigationBar.

, FilterBar, barTintColor . , .

- . , . , , CGColorSpaceGray, UIImageView CGColorSpaceRGB.

enter image description here

, , . , .

, Swift:

    let space : CGColorSpace = CGColorSpaceCreateDeviceRGB()
    let color : CGColor = CGColorCreate(space, [0.0, 0.0, 0.0, 0.3])

borderColor color borderWidth 0.5, . , UINavigationBar UIImageView . , , .

enter image description here

:

, UINavigationBar . _UINavigationBarBackground, , , .

, UINavigationBar . FilterBar.

enter image description here

:

, , , , UINavigationBar:

  • . barTintColor 85%. .

  • , 30%, , , , .

  • UINavigationBar, , .

FilterBar GitHub.

+13

All Articles