Some simple ideas of ios-uinavigationbar adding background picture

Source: Internet
Author: User

Uitabbarcontroller the following often need to set the navigation bar style for multiple viewcontroller, summed up the experience of adding a background image for the Uinavigationbar several simple ideas to set the background image as an example: the first kind, Set the Uinavigationbar of each view directly in the view, for each page requires a different navigation bar style. [Self.navigationController.navigationBar setbackgroundimage:[uiimage imagenamed:@ "nav_bg_all-64"] forbarmetrics: Uibarmetricsdefault]; the second type: Create a common basenavigationcontroller for each page and set up a background image. The other view controller inherits it, which can also achieve a holistic setting effect. [Self.navigationbar setbackgroundimage:[uiimage imagenamed:@ "nav_bg_all-64"] forbarmetrics:uibarmetricsdefault]; Third, write a method in Tabbarcontroller that is set by traversing the navigation bar of all views. Remember to call this method-(void) createnavigationbar{//traverse all views of the navigation bar for (Uinavigationcontroller *navi in self.viewcontrollers) {[ Navi.navigationbar setbackgroundimage:[uiimage imagenamed:@ "nav_bg_all-64"] forbarmetrics:uibarmetricsdefault];}} Fourth: Directly change the default style of the Uinavigationbar, which differs from the previous one in that it only changes the navigation bar of the five views, while the latter acts on Uinavigationbar. [[Uinavigationbar appearance] Setbackgroundimage:[uiimage imagenamed:@ "nav_bg_all-64"] forBarMetrics: Uibarmetricsdefault];

Some simple ideas of ios-uinavigationbar adding background picture

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.