0

I'm having an issue where my custom navigation view misaligns when the left and right buttons are different sizes. I'm using size classes and the constraints I've set are shown below:

enter image description here

This method has worked extremely well for me in the past but my designer requires that the right button be a rounded "save" instead of simple text. When viewed on iPhone 5 or 4 devices (narrow width) it misaligns and gets pushed to the left. Here is an example of how this looks on the device and in View Debugger.

enter image description here

enter image description here

I'm trying to avoid redoing all of my button images to be the same width and hoping there is a simple IB fix that I can add.

Any help would be greatly appreciated.

Sasha Reid
  • 1,547
  • 1
  • 10
  • 8
  • I think this is because both the buttons are of different width that's why u r facing this issue try to make both buttons of equal width this might solve your issue. – Milap Kundalia Feb 29 '16 at 18:10

1 Answers1

0

you can add 'Horizonatally in Container' constrain to Navigation Bar Title View. enter image description here

Thenceforth you can add trailing edges constrain(with or without margin) between save button and its superview. Similarly you can add leading edges constrain between back button and its superview. Take care that superview of all 3 views should be same. Hope it helps. Happy Coding. !!

*EDITED You can refer my ans here and for customisation here.

luckyShubhra
  • 2,731
  • 1
  • 12
  • 19
  • Hey Lucky. I tried to do the above but it didn't seem to help. I feel like the parent view's center has been pushed to the left and so creating a constraint against it has the same issue. – Sasha Reid Feb 29 '16 at 10:56
  • Images here: http://imgur.com/HET8uDV http://imgur.com/DKoJ09x http://imgur.com/Ic9nBe6 – Sasha Reid Feb 29 '16 at 11:04
  • can u show us constrain used in parent view...?? U just need to give leading and trailing constrain to parent view. Dont fix its width. – luckyShubhra Feb 29 '16 at 11:19
  • i have updated my ans. You can try Fixed Space Bar Button item as well as Flexible Space Bar Button item to achieve the same. I have attached links how to use the same.Hope it helps. – luckyShubhra Feb 29 '16 at 11:42
  • Thanks Lucky. I couldn't add a Fixed Space Bar Button Item into a UINavigationBar as these aren't designed for that (They're used in a Tool Bar). I think I'm just going to make the images on either side the same size instead of using constraints. Thanks anyway – Sasha Reid Mar 01 '16 at 02:58