-1

I have a UIButton

let leftButton = UIBarButtonItem(image: UIImage(named: "draggerMore.png"), style: .plain, target: self, action: #selector(crossBtnTapped))

and I set it as leftBarButtonItem

self.navigationItem.leftBarButtonItem  = leftButton

This button the only one in navigationItem.leftBarButtonItems The result is here:

enter image description here

I want the dagger to be close to the left side (as Restore button to the right).

I tried dif. ways from stack overflow such as subview.layoutMargins = UIEdgeInsets.zero in viewWillLayoutSubviews() but it didn't work for me. Maybe the problem is in back button which is invisible? How can I fix it?

Dima
  • 1,189
  • 1
  • 8
  • 12

1 Answers1

1

Instead of this:

    self.navigationItem.leftBarButtonItem = leftButton

Try this:

    self.navigationItem.backBarButtonItem = leftButton
UnuSynth
  • 108
  • 1
  • 5
  • I understood your idea, but the functionality of my button is different than back btn. Back btn doesn't appear in my case because I don't have previous controllers – Dima May 09 '20 at 17:46