iOS Development memo: Custom Uinavigationbar background picture and Back button

Source: Internet
Author: User

iOS projects, depending on the design diagram, sometimes need to customize the background of the UIView Uinavigationbar. You can cut out a background image of about 1 pixels to act as a uinavigationbar background.

Can take advantage of Navigationbar-(void) SetBackgroundImage: (UIImage *) backgroundimage forbarmetrics: (uibarmetrics) The Barmetrics method fills the picture with the Navigationbar background.

The specific code can refer to:

[Self.navigationController.navigationBar setbackgroundimage:[uiimage imagenamed:@ "navbarbj  [] forbarmetrics:uibarmetricsdefault];

One of the uibarmetricsdefault refers to the cell phone vertical direction of the navigationbar, another commonly used uibarmetricslandscapephone refers to the mobile phone landscape navigationbar.

Also on customizing the Back button, take Aview jump to bview for example.

One way is to customize a leftbarbuttonitem in the bview Navigationitem, which implements the return navigation operation. The code can refer to:

Uibarbuttonitem *barbuttonitemleft=[[uibarbuttonitem alloc] Initwithtitle:@ " back to home "  Style:uibarbuttonitemstylebordered target:self Action: @selector (Navigationtomainview)]; [[Self Navigationitem] setleftbarbuttonitem:barbuttonitemleft];

One way is to set the return button custom style in Aview. The specific code can refer to:

Uibarbuttonitem *backitem=[[Uibarbuttonitem alloc]init];    Backitem.title=@ "";    Backitem.image=[uiimage imagenamed:@ ""];self.navigationitem.backbarbuttonitem=backitem;

iOS Development memo: Custom Uinavigationbar background picture and Back button

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.