objective c - adding custom BarButtonItem to top navigation bar -


using interface builder in storyboard, put bar button item in top left corner of navigation toolbar toggles edit view of table view cells. have text "edit cells"

my question is, how change use image? created own custom image edit cells on state , edit cells off state, when specify image in interface builder, image stretched in bar button item. need make bar button item programmatically code make use frame of image? how specify state?

i feel there should way in interface builder tried programmatically:

uiimage *image = [uiimage imagenamed:@"edit-off.png"]; uibutton *showeditbutton = [uibutton buttonwithtype:uibuttontypecustom]; showeditbutton.bounds = cgrectmake( 0, 0, image.size.width, image.size.height ); [showeditbutton setimage:image forstate:uicontrolstatenormal]; uibarbuttonitem *showeditbuttonitem = [[uibarbuttonitem alloc] initwithcustomview:showeditbutton]; 

now how add showeditbuttonitem top left of navigation bar?

enter image description here

actual image:

enter image description here

icons in ios expected of size. can find of sizes of various icons want in ios human interface guidelines.

as setting different icons different states, believe need in code.

to set image uibarbuttonitem need set image property:

editbutton.image = editactiveimage; 

or

editbutton.image = editinactiveimage; 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -