How to add custom image in navigation bar button item?

前端 未结 12 1706
我寻月下人不归
我寻月下人不归 2020-12-13 09:26
 UIBarButtonItem *doneitem=[[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(donePressed:)]autorelease];
           


        
12条回答
  •  借酒劲吻你
    2020-12-13 09:55

    Do this. It's way more simple.

    1. Put the image file in your project directory

    2. Add the file into Xcode (Right click on the Xcode project, add files to "Project Name")

    3. Select your UIBarButtonItem in Storyboard

    4. Click on "Image" and find your image (See Screenshot)

    5. Celebrate, because it will work perfectly and it requires no unnecessary code.

    enter image description here

提交回复
热议问题