简体   繁体   中英

when navigationBar.isTranslucent is true, the backgroundImage of navigationbar become translucent too

In my first page, the navigation bar should be transparent, and when push to next page, the navigation bar should be a image. I worked it out by changing the _UIBarBackground or _UINavigationBarBackground 's alpha.

But I meet a big problem, in the first page, view should be placed and draw from (0,0) so I set the navigation bar's isTranslucent to true , that all works fine. But when I enter the next page, background image shows with a translucent looking which I don't want.

btw, I set background using:

navVC.navigationBar.setBackgroundImage(UIImage(named: "navigation_bar_background"),
                                       for: .default)

在此处输入图片说明

I checked the image used here, and it's not translucent.

What can I do with this issue? I don't want set viewController's extendedLayoutIncludesOpaqueBars to true due to ugly appearance when animation.

Combination of these 2 solutions will help.

http://ioscodeguide.blogspot.in/2014/01/navigation-bar-bagground-image.html

http://ioscodeguide.blogspot.in/2014/01/navigation-bar-font-style-and-font.html


In first view:

self.navigationController.navigationBar.tintColor = [UIColor clearColor];
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;

In 2nd view:

Set image to your navigationBar using the following link.

How to set Navigation Bar Bagground image - By - iOSCodeGUIDE


Adding to that To keep navigation bar transparent in first page and display on 2nd page,

1st Page viewwill appear Hide-Yes NavigationBarHide, and on view did disappear Hide-No

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM