3

I had setup two UIBarButtonItem on the left. Below is the screen shot of the wireframes of the screen, captured from debugging view hierarchy. Red box is the default back button and green box is the menu button.

From the screenshot, there is a gap between the back button image and menu button. The back button's view is occupying the extra space. I'm trying to figure out a way to get these two button close to each other.

I removed the "Back" text for the back button:

let backItem = UIBarButtonItem()
backItem.title = ""
self.backBarButtonItem = backItem

And added menu button:

let btn = UIBarButtonItem()
btn.customView = menu // it's a UIButton
self.leftItemsSupplementBackButton = true
self.leftBarButtonItem = menu

enter image description here

Ty Lertwichaiworawit
  • 2,950
  • 2
  • 23
  • 42
Srujan Simha
  • 3,637
  • 8
  • 42
  • 59

2 Answers2

0

If it truly is the back buttons view, then just reduce the size of its views frame and you are good to go.

If it is an attribute of the main back bar button item they give you, then make a custom one that looks the same and give it the appropriate size.

If you are using a flexible space bar button item, then use a fixed space bar button item and set it appropriately.

You can also modify the value of a bar button view's location through the insetInPlace() that you use on the frame, but that will take some experimenting on the correct values to be used.

Sethmr
  • 3,046
  • 1
  • 24
  • 42
0

There are few options:

One is to insert an invisible bar button item and give it negative width like shown here https://stackoverflow.com/a/31804099/520810

Alternatively you can adjust image insets https://stackoverflow.com/a/22742322/520810

Community
  • 1
  • 1
Sash Zats
  • 5,376
  • 2
  • 28
  • 42