I\'ve been developing an iOS app and have been having issues with using an image as the left bar button item in the navigation bar. I have attempted this in the following wa
Calling myButton.sizeToFit()
before assigning to leftBarButtonItem
helped me.
let cancelButton = UIButton()
cancelButton.backgroundColor = .red
cancelButton.setTitle("Common/Cancel".localized, for: .normal)
cancelButton.sizeToFit() //!!!
let cancelBarButton = UIBarButtonItem(customView: cancelButton)
navigationItem.leftBarButtonItem = cancelBarButton