Custom title bar buttons@implementationSntitlebutton- (ID) initWithFrame: (cgrect) frame{ Self=[Super Initwithframe:frame]; if(self) {//Center PictureSelf.imageView.contentMode =Uiviewcontentmodecenter; //Font RightSelf.titleLabel.textAlignment =Nstextalignmentright; //Font[self Settitlecolor:[uicolor blackcolor] forstate:uicontrolstatenormal]; Self.titleLabel.font= [Uifont systemfontofsize: -]; //highlight state slices do not change colorself.adjustsimagewhenhighlighted =NO; } returnSelf ;}//set the frame of the icon-(CGRect) Imagerectforcontentrect: (cgrect) contentrect{cgfloat imagey=0; CGFloat Imagew=Self.height; CGFloat Imageh=Self.height; CGFloat ImageX= Self.width-Self.height; returnCGRectMake (ImageX, Imagey, Imagew, Imageh);}//set the title of the frame-(CGRect) Titlerectforcontentrect: (cgrect) contentrect{cgfloat ImageX=0; CGFloat Imagey=0; CGFloat Imagew= Self.width-Self.height; CGFloat Imageh=Self.height; returnCGRectMake (ImageX, Imagey, Imagew, Imageh);}@endCall the custom navigation bar caption button in the controller Sntitlebutton*titlebutton =[[Sntitlebutton alloc]init]; //text[Titlebutton Settitle:@"Home Page"Forstate:uicontrolstatenormal]; [Titlebutton Settitlecolor:[uicolor Blackcolor] forstate:uicontrolstatenormal]; //Image[Titlebutton setimage:[uiimage imagenamed:@"Navigationbar_arrow_down"] Forstate:uicontrolstatenormal]; [Titlebutton setbackgroundimage:[uiimage resizedimage:@"navigationbar_filter_background_highlighted"] forstate:uicontrolstatehighlighted]; //DimensionsTitlebutton.width = -; Titlebutton.height= *; Self.navigationItem.titleView= Titlebutton;
Custom navigation Bar Caption button