Ios Swift : Adding or Moving NavigationBar to bottom of the view controller - ios

I want to move the navigation controller bar to the bottom of the view controller. How can i get this done ?
I tried :
self.navigationController!.navigationBar.frame = CGRectMake(
0,
UIScreen.mainScreen().bounds.height - 50,
UIScreen.mainScreen().bounds.width,
50)
This is moving to the bottom but hiding all other controller objects and also back button is not woking.

Sujay U N,
You should not try to move the UINavigationBar provided by the embeded UINavigationController to the bottom of the screen. Trying that will obvisoulsy move all the view's below it causing all the controller objects to hide.
Workaround
Approach 1:
Consider using ToolBar :)
Toolbar is designed to be placed at the bottom of the screen. If you are using xib or storyboard you can pick toolbar from components library and place it on your ViewController's bottom and then apply autoresizing masks or constraints properly :)
Now in order to show the back button make use of UIBarButtonItems. Change the style to custom and provide it arrow image or provide default style as done.
Though now you are all set to go :) You will notice UINavigationBar at the top of your view controller. In order to get rid of it,
select your ViewController, select its TopBar property set it to none :)
Approach 2
Use UINavigationBar.
Specific about using Navigation bar and dont want to use toolbar, well you can do the same thing with UINavigationBar as well.
Drag the UINavigationBar from components library place it at the bottom of the screen. Drag the UIBarButtonItem drop it as leftBarButtonItem, change the barButtonItem image to your back image. ( Same process as UIToolBar just use UINavigationBar instead)
Understand this is not same as the navigation bar provided by the embeded NavigationController. So get rid of NavigationBar at the top of your ViewController same as I explained above here as well
Finally,
In both the cases, draw an IBoutlet from barbutton item and handle poping the viewController programmatically.
Happy coding :)

Related

Common blur effect for top tool bar and navigation bar

I have many ViewControllers inside one NavigationController. In one of ViewControllers I should show toolBar below navigationBar. If simply add it to ViewController with necessary coordinates I have this:
But here is separator between NavigationBar and ToolBar.
If I set clear background and shadow images and set blur effect for navigationBar it is a problem with different blur effects in navigationBar and toolBar:
So is it resolution when there is no imagesShadow in navigationBar and there is common blur effect?
I resolve my problem. Idea of resolution make NavigationBar and ToolBar fully transparent. Next On every ViewController in place of bars and below them I put UIVisualEffectView with common height of bar or bars. So UIVisualEffectView simply should be the highest subview of rootView of ViewController. And here is a problem in case of using UITalbeViewController UITabBarController and so on. In my situation there was only UITalbeViewControllers. Firstly I try to use this resolution. But I had problems with creating of multiple subviews wile navigation via different ViewControllers. Finaly I restructure storyboard. Every TableViewController I have replaced by ViewController with rootView simple view. TableView was subview of rootView. Also I put there VisualEffectView. I have done it for every TableViewControllers.
Here is a sample of structure:
I think there is there better resolution but currently this is optimal.

Recreate UITabBar to UIToolbar on select from Photos app

I need to do exactly what the photos app is doing when you press the select button. Basically just hides the UITabBar and presents a UIToolbar. For some reason this seems to be incredibly difficult if you don't want to implement a complete hack. I found a hack if you shrink the height of the UITabBar and change it's alpha to 0 but when you set it's height back to the default the image and text is condensed.
Turns out that I ended up just needing to call [self.tabBarController.tabBar setHidden:YES] to hide the tabBar and instead of using my existing UINavigationController's toolbar I create my own instance of a UIToolbar and add it as a subview of my view controller. Then using autolayout I pinned it to the leading, trailing, and bottom edge of the view. This handles rotation and other issues.

TabBar in TableViewController is not at the bottom

I am trying to add a tabBar to my TableViewController but it is not a the bottom it just act like a cell
Here is a screenShot:
When using a UITableviewController storyboard scene, every Tab Bar or Toolbar you drag in it is automatically put into the tableView tableFooterView.
If you don't want that, you have to create an UIViewController scene. You will therefore be able to drag your Tab Bar or Toolbar in it, set its auto layout constraints and then add your UITableView in the UIViewController scene (see image below).
However, there is another solution. Select your Navigation Controller scene and go to the Attributes Inspector. In the Simulated Metrics, go to Bottom Bar and select "Translucent Tab Bar" or "Translucent toolbar". Then, select your UITableviewController scene and repeat the previous operation (see the picture below).
If you do so, all controllers following your Navigation Controller will have a Tab Bar or Toolbar (that's another problem that can also be fixed).
Use autoLayout to pin it to the bottom

adding Button on UITtabbar and My button must be higher than TabBar (Objective C)

I'm working on UITabBarController. And now i want to add Button in the middle of UITabBar. The problem is my button must be higher than TabBar. In other words half of my button is out of TabBar. Is it possible? if it is possible, how can i do that? Thanks.
You can cover the UITabBarController with a UIView that has buttons. Use the buttons to programmatically select the correct tab. make the UIView have a clear background and be the height of the tallest button on the bar.

Nav bar button bigger than the nav bar height

Let's have a a picture :
Is there a way to have a Navbar button bigger than the navbar it self, like the "O" button ?
Or If not, what is the best hack if i want to trie to have this renderer ?
I think the best way it make custom viewcontroller which support this logic.
For example you can create custom viewcontroller with method setNavigationBarByType:(YourType)
Then use this viewcontroller as parent viewController
Try with clipSubview = NO for UINavigationBar --> Its UIView property so it should work over UINavigationBar as well but I'm not sure about this
Instead of using UINavigationBar use custom controls like,
UIView as a containerView
--Backround UIImageView
--Back UIButton Custom style
--Right UIButton Custom style
Display this containerView in your RootViewController where you require to put common controls of your application. and the middle part of screen will be populated as per button tap event or screen flow.
Hope this will help you.
Create UILabel configure and set as navigation bar title view.
Added this button as subview to navigation bar title view.

Resources