I have a view with a transparent UINavigationBar
and a UITableView
about 10px below it. There's a UIImageView
with a cool polygon image in the background that I'm animating in a parallax-y way for view transitions.
Here's the code for the transparent nav bar:
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
I'm not using storyboards at all for this project
I also have a floating action button down in the bottom right. The nav bar title UILabel
I've added to the titleView
is swapped for a UITextField
for search functionality on tap of a right nav button. When this happens, I'm setting
self.navigationController.navigationBar.translucent = YES;
This all works well, except that by setting translucent = NO
the view pushes the all of the content down by the height of the nav bar.
I can hack together some frame changes to compensate for this, but I was wondering if there was a more standard practice solution for this.
The property you want to set is extendedLayoutIncludesOpaqueBars
, if this property is set to YES then your view will layout the same as if the navigation bar were translucent.
You mentioned that you're not using storyboards, but for others who do this can be set in the Attributes Inspector for the view controller under the 'Extend Edges' section by ticking the checkbox titled 'Under Opaque Bars'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With