iphone - Adding leftbarbuttons and custom title to navigation bar in iOS -
i adding custom title , leftbar buttons navigation bar using following code:-
uibarbuttonitem *button1 =[[uibarbuttonitem alloc]initwithimage:[uiimage imagenamed:@"img1.png"] style:uibarbuttonitemstyleplain target:self action:@selector(popback)]; uibarbuttonitem *button2 =[[uibarbuttonitem alloc]initwithimage:[uiimage imagenamed:@"img2.png"] style:uibarbuttonitemstyleplain target:self action:nil]; self.navigationitem.leftbarbuttonitems = [[nsarray alloc] initwith:button1, button2, nil]; uilabel *label = [[uilabel alloc] initwithframe:cgrectmake(0, 0, 360, 30)]; [label setfont:[uifont fontwithname:@"arial-boldmt" size:14]]; [label setbackgroundcolor:[uicolor clearcolor]]; [label settextcolor:[uicolor whitecolor]]; [label settext:@"detail controller"]; label.textalignment = uitextalignmentcenter; //nstextalignmentcenter self.navigationitem.titleview=label;
here, left bar buttons not been placed , title alignment not coming properly(left bar buttons pushing title right side of navigation bar).
Comments
Post a Comment