IOS-Change Navigationbar background picture-picture horizontal repetition problem

Source: Internet
Author: User
Tags repetition

When you use a function

-(void) SetBackgroundImage: (Nullable UIImage *) backgroundimage forbarmetrics: (uibarmetrics) Barmetrics

When setting the background picture for the navigation bar, if the incoming picture is not processed, it will cause the problem of horizontal repetition of the picture in 6 and 6s (in case the picture itself is not wide enough)

Workaround: Process the incoming picture, using the UIImage function

-(UIImage *) Resizableimagewithcapinsets: (uiedgeinsets) capinsets Resizingmode: (uiimageresizingmode) ResizingMode

Examples:

UIImage *bgimage = [[UIImage imagenamed:@ "Cei_bg_header"] resizableimagewithcapinsets:uiedgeinsetsmake (0, 0, 0, 0) Resizingmode:uiimageresizingmodestretch]; [[Uinavigationbar appearance] Setbackgroundimage:bgimage Forbarmetrics:uibarmetricsdefault];

Reference: Http://stackoverflow.com/questions/26052454/ios-8-navigationbar-backgroundimage

IOS-Change Navigationbar background picture-picture horizontal repetition problem

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.