How to add an image to a button?

How to add image to navigation back button

  • I have a backbutton image (backButton). How can I add it to the back button of the navigation bar? UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"backButton"] style:UIBarButtonItemStylePlain target:nil action:nil]; viewController.navigationItem.backBarButtonItem = newBackButton; [newBackButton release]; However, I am getting a weird looking button as seen below. How can I replace the backbutton with the full black back button image?

  • Answer:

    You'll have to modify the black image's pixel size. Open up the image in any image editor, go to the adjust image size (it may be called something else in a different photo editor) find out the size and pixels. It looks like you'll have to make the thing 1 pixel taller and like 2 pixels wider, but I'm not sure. You can probably find some documentation on the exactly pixel size of the navigation button and work with that. Goodluck

Zhen at Stack Overflow Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.