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

Sujay U N

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.

Sandeep Bhandari

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 :)

enter image description here

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. enter image description here

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 :) enter image description here

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)

enter image description here

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 :)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

NavigationBar not showing up (View Controller) : Swift

From Dev

iOS Swift: Adding bottom insets between section in Table View

From Dev

In a table view controller when adding a container view, how can I move it to the very bottom? (Swift)

From Dev

adding searchBar to navigationBar in swift

From Dev

Moving View Controller to the top of navigation stack iOS

From Dev

Moving to another view controller in iOS on Button Click

From Dev

adding view controller as child view in ios

From Dev

iOS - Adding Subviews to Child View Controller view

From Dev

Swift / How to hide NavigationBar with Root View Controller / Page View Controller. Little gap on top of screen

From Dev

NavigationBar not appearing in second view controller

From Dev

iOS adding a UISearchController is unhiding the NavigationBar

From Dev

iOS adding a UISearchController is unhiding the NavigationBar

From Dev

swift ios adding search bar to picker view

From Dev

Push Up View Controller from Bottom using Swift

From Dev

iOS Swift, returning to the same instance of a view controller

From Dev

ios swift cannot dismiss view controller

From Dev

iOS Swift, returning to the same instance of a view controller

From Dev

iOS Swift always start with same view controller

From Dev

Adding swift file to new view controller in xCode? (easy)

From Dev

Swift - Adding background image behind a Sprite Kit Scene in View Controller

From Dev

Moving from Navigation controller to parent view controller

From Dev

Moving Tab Bar Controller in iOS

From Dev

Swift IOS: several buttons in one view controller, control the image view display in another view controller

From Dev

iOS8 Swift UISearchController hides navigationbar

From Java

Adding a view controller as a subview in another view controller

From Dev

How to remove bottom shadow for navigationBar in swift3

From Dev

Adding rows to static table view programmatically in swift iOS 9

From Dev

Adding rows to static table view programmatically in swift iOS 9

From Dev

Remove Navigationbar's bottom border iOS7

Related Related

  1. 1

    NavigationBar not showing up (View Controller) : Swift

  2. 2

    iOS Swift: Adding bottom insets between section in Table View

  3. 3

    In a table view controller when adding a container view, how can I move it to the very bottom? (Swift)

  4. 4

    adding searchBar to navigationBar in swift

  5. 5

    Moving View Controller to the top of navigation stack iOS

  6. 6

    Moving to another view controller in iOS on Button Click

  7. 7

    adding view controller as child view in ios

  8. 8

    iOS - Adding Subviews to Child View Controller view

  9. 9

    Swift / How to hide NavigationBar with Root View Controller / Page View Controller. Little gap on top of screen

  10. 10

    NavigationBar not appearing in second view controller

  11. 11

    iOS adding a UISearchController is unhiding the NavigationBar

  12. 12

    iOS adding a UISearchController is unhiding the NavigationBar

  13. 13

    swift ios adding search bar to picker view

  14. 14

    Push Up View Controller from Bottom using Swift

  15. 15

    iOS Swift, returning to the same instance of a view controller

  16. 16

    ios swift cannot dismiss view controller

  17. 17

    iOS Swift, returning to the same instance of a view controller

  18. 18

    iOS Swift always start with same view controller

  19. 19

    Adding swift file to new view controller in xCode? (easy)

  20. 20

    Swift - Adding background image behind a Sprite Kit Scene in View Controller

  21. 21

    Moving from Navigation controller to parent view controller

  22. 22

    Moving Tab Bar Controller in iOS

  23. 23

    Swift IOS: several buttons in one view controller, control the image view display in another view controller

  24. 24

    iOS8 Swift UISearchController hides navigationbar

  25. 25

    Adding a view controller as a subview in another view controller

  26. 26

    How to remove bottom shadow for navigationBar in swift3

  27. 27

    Adding rows to static table view programmatically in swift iOS 9

  28. 28

    Adding rows to static table view programmatically in swift iOS 9

  29. 29

    Remove Navigationbar's bottom border iOS7

HotTag

Archive