ios - UIBarButtonItem - changing background and removing text -


i'm trying change done button in presentviewcontroller in navbar succesfully able change background using this:

[[uinavigationbar appearance] setbackgroundimage:[uiimage imagenamed:@"nav_bg.png"] forbarmetrics:uibarmetricsdefault]; 

now, when changing done button replacing image, image repeating , done text stays there. using this:

uiimage *donebackgroundimage = [[uiimage imagenamed:@"back-home.png"]                                             resizableimagewithcapinsets:uiedgeinsetsmake(0, 0, 0, 0)];              [[uibarbuttonitem appearance] setbackgroundimage:donebackgroundimage                                                     forstate:uicontrolstatenormal                                                        style:uibarbuttonitemstyledone                                                   barmetrics:uibarmetricsdefault]; 

this looks like: enter image description here

what doing wrong here please?

step : 1

create uibutton , assign uibarbuttomitem using initwithcustomview in presentviewcontoller

uiimage *customimage = [uiimage imagenamed:@"yourcustomimage"]; uibutton *custombutton = [uibutton buttonwithtype:uibuttontypecustom]; backbutton.frame = cgrectmake(0, 0, customimage.size.width, customimage.size.height); [backbutton setimage:[uiimage imagenamed:@"yourcustomimage"] forstate:uicontrolstatenormal]; [backbutton addtarget:self action:@selector(showpreviousview) forcontrolevents:uicontroleventtouchupinside];  uibarbuttonitem *leftbarbutton = [[uibarbuttonitem alloc]initwithcustomview:custombutton]; 

step :2

you can find more so post

 viewcontroller.navigationitem.titleview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"yourimage.png"]];     uibarbuttonitem * item = [[uibarbuttonitem alloc] initwithcustomview:[[uiimageview alloc] initwithimage:[uiimage imagenamed:@"yourimage2.jpg"]]];         viewcontroller.navigationitem.rightbarbuttonitem = item;  

Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -