About customizing the navigation bar Uibarbuttonitem offset

Source: Internet
Author: User

When you customize the left button of the navigation bar, the position of the button is shifted to the right, and the workaround is given below.

It also relies on the property settings of the UIButton

Set the left button of the navigation bar

UIButton *leftbutton = [UIButton buttonwithtype:uibuttontypecustom];

Leftbutton.frame = CGRectMake (0, 0, 32, 26);

Leftbutton.imageedgeinsets = Uiedgeinsetsmake (0,-13, 0, 0);//Set the offset position of the button picture (left offset)

[LeftButton setimage:[uiimage imagenamed:@ "Shouye-cehua"] forstate:uicontrolstatenormal];

[LeftButton addtarget:self Action: @selector (handleleftbuttonaction:) forcontrolevents:uicontroleventtouchupinside ];

Self.navigationItem.leftBarButtonItem = [[Uibarbuttonitem alloc] Initwithcustomview:leftbutton];

About customizing the navigation bar Uibarbuttonitem offset

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.