Nitesh
Nitesh

Reputation: 2034

Add image to Navigation Bar Back Button

I want to have the back button with "< [IMG]" instead of "< Back" which is by default.

let barAppearace = UIBarButtonItem.appearance()
barAppearace.setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -60), for:UIBarMetrics.default)

with this I have removed the text but how to add an image next to the "<".

Upvotes: 3

Views: 841

Answers (2)

Aman Gupta
Aman Gupta

Reputation: 995

let backButton = UIBarButtonItem(image:UIImage(named: "ic_authors_detail_back.png"), style:.Plain, target:self, action:"backButtonPressed");
backButton.tintColor = UIColor(hexString: "#ffffffff")
let leftBarButtonsArray = [backButton]
navigationItem.leftBarButtonItems = leftBarButtonsArray

Here is the code to add a button on navigation bar.Hope this helps

Upvotes: 2

Amanpreet
Amanpreet

Reputation: 1321

When you click left bar button

enter image description here

You can set its attribute like:

enter image description here

Here is option to set image.

Upvotes: 0

Related Questions