2

After installed the right hand bar buttons my page title become dealigned. Is there a way to realign it in the centre of the page?

Haven't found a way to do in with the storyboard, but I imagine that may be possible programmatically?!

enter image description here

GuiSoySauce
  • 1,763
  • 3
  • 24
  • 37
  • May be duplicated here: http://stackoverflow.com/questions/9921026/center-custom-title-in-uinavigationbar – Long Pham Oct 02 '15 at 02:51
  • Explain how you make the title. – matt Oct 02 '15 at 02:53
  • 1
    Similar issue, but I think I made clear on the question and tags I am looking for a solution using swift syntax, not objective C. Not to mention deprecated methods from objective C that no longer work on Swift. – GuiSoySauce Oct 02 '15 at 10:26
  • I have a navigation controller, that controls this view. So the title has been written using the storyboard. It is not programmatically done. The buttons are also done using the storyboard. I've inserted a view onto the navbar and buttons into this view. So, all storyboard done. – GuiSoySauce Oct 02 '15 at 10:27
  • Did you fixed this issue? – Vishnu Kumar. S Apr 08 '16 at 10:15

1 Answers1

0

Your title might be too wide. Try to add a background color and see how much it's span.

I had a similar issue.

What I did is to add an empty image on the left side to balance the nav bar:

private func alignWithWhiteSpace() -> UIBarButtonItem
{
    let menuBtn = UIButton()

    menuBtn.userInteractionEnabled = true
    menuBtn.frame = CGRectMake(0, 0, 25, 25)
    menuBtn.setImage(UIImage(named: "empty image"), forState: .Normal)

    let menuBtnItem = UIBarButtonItem()
    menuBtnItem.customView = menuBtn
    return menuBtnItem
}
Manu
  • 629
  • 7
  • 6