SetNavigationBar translucent pushes down

I have a view with transparent ones UINavigationBarand UITableViewabout 10px under it. There is a UIImageViewcool image of a polygon in the background, which I animate in parallax-y mode for viewing.

Here is the code for the transparent navigation bar:

self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];

I do not use storyboards at all for this project

I also have a button with a floating action down in the lower right corner. The navigation bar title UILabeladded to titleViewis replaced by UITextFieldfor the search function when you press the right navigation button. When this happens, I install

self.navigationController.navigationBar.translucent = YES;

All this works well, except that by setting translucent = NOit to view, it pushes all the content down the height of the navigation bar.

enter image description here Search mode

, , , .

+4
1

, , extendedLayoutIncludesOpaqueBars, YES, , .

, , , , " ", " ".

+9

Source: https://habr.com/ru/post/1614320/


All Articles