iphone - UIBarButtonItem width with a two-line label -


i know how can rid of spaces left , right two-line label in uibarbuttonitem, has view set setcustomview follows:

uibutton* forwardbutton = [uibutton buttonwithtype:101];  [forwardbutton settransform:cgaffinetransformmakescale(-1.0, 1.0)]; [forwardbutton.titlelabel settransform:cgaffinetransformmakescale(-1.0, 1.0)];  [forwardbutton settitle:@"now\nplaying" forstate:uicontrolstatenormal]; [forwardbutton addtarget:self action:@selector(openplayer) forcontrolevents:uicontroleventtouchupinside];  [forwardbutton.titlelabel setnumberoflines:2]; [forwardbutton.titlelabel setlinebreakmode:nslinebreakbywordwrapping]; [forwardbutton.titlelabel settextalignment:nstextalignmentcenter]; [forwardbutton.titlelabel setfont:[uifont boldsystemfontofsize:10]];  [navbutton setcustomview:forwardbutton]; 

here result get.

the width of button if label had text written in 1 line this.

you try changing bounds button.

uibutton* forwardbutton = [uibutton buttonwithtype:101]; [forwardbutton settransform:cgaffinetransformmakescale(-1.0, 1.0)]; [forwardbutton.titlelabel settransform:cgaffinetransformmakescale(-1.0, 1.0)];  [forwardbutton settitle:@"now\nplaying" forstate:uicontrolstatenormal]; [forwardbutton.titlelabel setnumberoflines:2]; [forwardbutton.titlelabel setlinebreakmode:nslinebreakbywordwrapping]; [forwardbutton.titlelabel settextalignment:nstextalignmentcenter]; [forwardbutton.titlelabel setfont:[uifont boldsystemfontofsize:10]];  forwardbutton.bounds = cgrectmake(0, 0, 30, 30);   uibarbuttonitem* forwardbuttonitem = [[uibarbuttonitem alloc] initwithcustomview: forwardbutton]; self.navigationitem.rightbarbuttonitem = forwardbuttonitem; 

tested , works


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -