I want to add left bar button item in navaigationBar
.
I have back button sign (do not have any text) in left side and when I add leftBarButtonItem
then I can not see the back button.
How can I solve this problem.
This is my code:
let phonePhoto = UIButton()
phonePhoto.setImage(UIImage(named: "navigationPhone"), for: UIControlState())
phonePhoto.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
phonePhoto.addTarget(self, action: #selector(userEdit), for: .touchUpInside)
let userPhone = UIBarButtonItem()
userPhone.customView = phonePhoto
self.navigationItem.leftBarButtonItem = userPhone
The presence of custom left bar button items causes the back button to be removed in favor of the custom items. Set navigationItem
property leftItemsSupplementBackButton
to true
will display back button also with your custom left bar item.
self.navigationItem.leftItemsSupplementBackButton = true
Check Apple Documentation on leftItemsSupplementBackButton
for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With