Hi Alex here from rebeloper.com and the welcome back to these Extensions
Tutorial series and today we are going to talk about another awesome navigation
extension and that is to hide the background of our and navigation item so
without further ado let's jump right into it!
In the previous episode we
have created this pop to left or a push from left navigation let's say
transition and we had our navigation bar but what if we wanted to change that
navigation bar to be transparent entirely. Let me just build and run
and show you what we have achieved and basically we want to get rid of this
grayish stuff. Okay, maybe you just want to have these buttons and the navigation
title, who knows. And today we are going to do just that.
Okay, and it is pretty straightforward let's go to extensions and this will be
also a really short tutorial video not typical of the channel but here we have
our hideNavigationItemBackground. And I'm just going to paste the code in
and go through it with you line by line. Okay, we set the background image of our
navigation bar to be UI image for UI metrics default. Basically we add in a
default UIImage. A UIImage that isn't actually an image. We set the shadow
image the same way and we set isTranslucent to be true. And we set the
viewsBackgroundColor to be clear. Now we need to have all of these four in
place to get rid of let's say the background of
the navigation item. Now you could tweak and test but believe me this will save
you a ton of time. Okay! Now what we need to go do is go to NavigationViewController
and once we set up our navigation here. Let's say we said the
navigation title and what we want to do here is type in a navigation controller
and I believe it was... let's see what was the name of the extension again
hideNavigationItemBackground and that is it.
Let's begin run again and see the magic happen. There we go! No navigation
item background and to prove it we are going to push from right as you can see
the whole window, you can see the whole window we don't have that
navigation grey at all. Let's go back and push from left just so you can see
we have everything is green pop to left. There we go and that is how easy it is
to have let's say a transparent or let's say hidden navigation item background
it's kind of a mouthful but that's what it is in your apps. Now if you are
interested in this push from left extension go ahead and take a look at
the previous video and if you like this one go ahead and give it a thumbs up
subscribe to the channel and hit that notification bell to get notified of new
videos that I put up. And there is still one last video in this tutorial series
and that is... let me just check here... it is about the application and we are
going to get the top-most view controller and we will see that in
the next video!