1. Custom button
// left button
UIButton *leftbtn = [[UIButtonalloc]initwithframe:rectwithpara(- 0, (, )] ;
< Span style= "COLOR: #ffad10" > [leftbtn addtarget: self action: @ Selector (btnclicked:) forcontrolevents: uicontroleventtouchupinside];//set button click event
< Span style= "Color:rgb (255,173,16)" > [leftbtn setbackgroundimage: imagenamed @" Ic_fanhui_normal.png " Span style= "Color:rgb (255,173,16)") Forstate: Uicontrolstatenormal //set button normal state picture
[leftbtn setbackgroundimage:imagenamed(@ "Ic_fanhui_pressed.png" )forstate:uicontrolstateselected];//Set button to select the picture
2. Initialize Uibarbuttonitem
uibarbuttonitem *leftbarbuton = [[uibarbuttonitemalloc]initwithcustomview: LEFTBTN];
3. Adjust the position and set the left icon of the navigation bar
// adjust the position of Leftbarbuttonitem under IOS7
if([[[[[uidevicecurrentdevice] systemversion] Floatvalue]>=7.0? - : 0 ))
{
uibarbuttonitem *negativespacer = [[uibarbuttonitemalloc]initwithbarbuttonsystemitem:uibarbuttonsystemitemfixedspace
target:nilaction:Nil];
Negativespacer. width =------this value can be changed freely according to the situation
Self. Navigationitem. leftbarbuttonitems =@[negativespacer, Leftbarbuton];
}Else
self. Navigationitem. Leftbarbuttonitem = Leftbarbuton;
Solve the problem of customizing the left button of the navigation bar on the right after ios7.0