ios - changing text of custom navigation bar item -


i creating custom uinavigationbar barbuttonitem follows:

 // set bar button items     uibutton *backbutton = [[uibutton alloc] initwithframe:cgrectmake(0, 0, 35.0f, 35.0f)];     [backbutton setimage:[uiimage imagenamed:@"myimg.png"] forstate:uicontrolstatenormal];     [backbutton addtarget:self action:@selector(myselector) forcontrolevents:uicontroleventtouchupinside];      self.navigationitem.leftbarbuttonitem = [[uibarbuttonitem alloc] initwithcustomview:backbutton]; 

this working perfectly, when go set title of uibutton or barbuttonitem, won't show up. suggestions?

tried...

    [backbutton settitle:@"edit" forstate:uicontrolstatenormal];     [backbutton settitlecolor:[uicolor whitecolor] forstate:uicontrolstatenormal]; 

and...

     self.navigationitem.leftbarbuttonitem.title = @"edit"; 

without luck.

the problem image , title use same viewspace display.

so when use image title first show image , title (right side of image).

if size of uibutton same image can't see title.

a simple solution set image in background. try this:

[backbutton setbackgroundimage:[uiimage imagenamed:@"myimg.png"] forstate:uicontrolstatenormal]; 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -