Adjust the spacing between Leftbarbuttonitem and rightbarbuttonitem on the navigation bar and screen boundaries

Source: Internet
Author: User

UIButton *btn = [UIButton buttonwithtype:uibuttontyperoundedrect];
/**
* Set Frame to control button size only
*/
Btn.frame= cgrectmake (0, 0, 40, 44);
[Btn addtarget:self Action: @selector (buttonclicked) forcontrolevents:uicontroleventtouchupinside];
Uibarbuttonitem *btn_right = [[Uibarbuttonitem alloc] initwithcustomview:btn];
Uibarbuttonitem *negativespacer = [[Uibarbuttonitem alloc]
Initwithbarbuttonsystemitem:uibarbuttonsystemitemfixedspace
Target:nil Action:nil];
/**
* Width is negative, equivalent to BTN to the right to move the width of the value of pixels, because the button itself and the boundary spacing is 5pix, so width is set to 5, the spacing is exactly adjusted
* When the 0;width is positive, the opposite is the equivalent of moving the width to the left by a number of pixels
*/
Negativespacer.width =-5;
Self.navigationItem.rightBarButtonItems = [Nsarray arraywithobjects:negativespacer, btn_right, nil];
[Btn_right release];

Adjust the spacing between Leftbarbuttonitem and rightbarbuttonitem on the navigation bar and screen boundaries

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.