iOS: How to set a view background picture

Source: Internet
Author: User

1. Use a Uiimageview instance to make a child view, and put the last face
Uiimageview *custombackgournd = [Uiimageview alloc] initwithimage:[uiimage imagenamed:@ "background.jpg"];
Self.background = Custombackground;
[Custombackground release];

[Self addsubview:background];
[Self sendsubviewtoback:background];

If you are using IB, add Uiimageview to the Xib file and put it at the bottom.

2.

Self.view.backgroundColor = [Uicolor colorwithpatternimage:[uiimage imagenamed:@ "Background.jpg"];

Recommended use this, convenient.

Use in code today

Self.view.backgroundColor = [uicolorcolorwithpatternimage:[uiimageimagenamed:@ "[email protected]"];

The result [email protected] This picture was originally 640x960, the results show only the left half out with the top half out.

The correct code should be

Self.view.backgroundColor = [Uicolor colorwithpatternimage:[uiimage imagenamed:@ "INSTRUMENT_BG"];

In this case, the image will be automatically matched.

The wrong wording led to a twice-fold enlargement of the image, so it looked half-done. In addition the suffix of the picture is generally omitted as well

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.