IOS7 some problems with custom Uibarbuttonitem

Source: Internet
Author: User

The Barbuttonitem of the custom navigation bar under iOS will have some offset problems,

Solution: Adjust your item by creating a new system with a fixed-distance item

#defineIos7_navi_space-10} [Self.navigationitem setleftbarbuttonitems:[self getbackbarbuttonitem];}//Back button-(Nsarray *) getbackbarbuttonitem{//Custom ButtonUIButton *button=[[uibutton Alloc] Initwithframe:cgrectmake (0,0, -, *)]; //set a background picture[Button Setbackgroundimage:[uiimage imagenamed:@"Nav_left_btn_unselected.png"] Forstate:uicontrolstatenormal]; //Set Text[Button Settitle:@"return"Forstate:uicontrolstatenormal]; Button.titleLabel.font=[uifont systemfontofsize: -]; //Set Text color[button Settintcolor:[uicolor Whitecolor]; //add behavior for Touchupinside[button addtarget:self action: @selector (Backaction) forcontrolevents:uicontroleventtouchupinside]; //Initialize a barbuttonitemUibarbuttonitem *item=[[Uibarbuttonitem alloc] Initwithcustomview:button]; //a barbuttonitem placeholder with a fixed distance in the initialization of a systemUibarbuttonitem *fixedspace=[[Uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemfixedspace target:self Action:nil]; Fixedspace.width=ios7_navi_space;//Set width
Put the item with a fixed distance in front and adjust the distancereturn[[Nsarray alloc] initwithobjects:fixedspace,item, nil];}

IOS7 some problems with custom Uibarbuttonitem

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.