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
Post a Comment