Navigate VC's left and right item code

Source: Internet
Author: User

The code controls the left and right item:
   UIButton *btncancel = [UIButton buttonwithtype:uibuttontypecustom];    btncancel.frame=cgrectmake (0, 0, 60, 3 0);    btncancel.titlelabel.font=[uifont systemfontofsize:13];    Btncancel.contenthorizontalalignment = uicontrolcontenthorizontalalignmentleft;    [BtnCancel setTitle:@] Back to "forstate:uicontrolstatenormal];    [btncancel addtarget:self action: @selector (Buttoncancel:) forcontrolevents:uicontroleventtouchupinside];    self.navigationitem.leftbarbuttonitem=[[ Uibarbuttonitem Alloc] initwithcustomview:btncancel];        UIButton *btncommit = [UIButton buttonwithtype:uibuttontypecustom];    Btncommit.frame=cgrectmake (0, 0, max);    Btncommit.titlelabel.font=[uifont systemfontofsize:13];    Btncommit.contenthorizontalalignment = uicontrolcontenthorizontalalignmentright;    [Btncommit settitle:@ "submit" forstate:uicontrolstatenormal];     [Btncancel addTarget:self Action: @selector (commitaction:) forcontrolevents:uicontroleventtouchupinside];    Self.navigationitem.rightbarbuttonitem=[[uibarbuttonitem alloc] initwithcustomview:btncommit];


Other methods:
The first type: This setting out of the appearance of bad control UIImage *searchimage=[uiimage imagenamed:@ "Search.png"]; Uibarbuttonitem *barbtn=[[uibarbuttonitem alloc] Initwithimage:nil style:uibarbuttonitemstyledone target:self action        : @selector (Searchprogram)];    Barbtn.image=searchimage; self.navigationitem.rightbarbuttonitem=barbtn;//Second type: This picture will fill the button, the size controllable Uibutton*rightbutton = [[UIButton alloc]    Initwithframe:cgrectmake (0,0,30,30)];    [Rightbutton setimage:[uiimage imagenamed:@ "Back.png"]forstate:uicontrolstatenormal];    [Rightbutton addtarget:self Action: @selector (Backto) forcontrolevents:uicontroleventtouchupinside];    Uibarbuttonitem*rightitem = [[Uibarbuttonitem Alloc]initwithcustomview:rightbutton];  Self.navigationitem.leftbarbuttonitem= Rightitem; The Third Kind: uibarbuttonitem *anotherbutton = [[Uibarbuttonitem alloc] Initwithbarbuttonsystemitem: Uibarbuttonsystemitembookmarks target:self Action: @selector (Methodtocall:)]; How to make Navigationitem.rightbarbuttonitem hide away? Self.navigationitem.rightbarbuttonitem=nil; can be achieved 

  


  

Navigate VC's left and right item code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.