Several ways to stretch iphone pictures

Source: Internet
Author: User

Several ways to stretch iphone pictures

Uiimageresizingmodetile and Uiimageresizingmodestretch two modes, from the name can be seen, is the tiling mode and stretching mode. Tiling is the insets of the rectangular area you specify to fill the area of the picture you specify, and the stretch is to fill the area of the picture you want by stretching the block of rectangular area you insets specify.

After the system has been IOS6, the method of image stretching has been extended to 3 functions:

1.ios4 provides the method:

    1. -(UIImage *) Stretchableimagewithleftcapwidth: (Nsinteger) leftcapwidth topcapheight: (Nsinteger) topcapheight
    2. This function is an instance of UIImage function, its function is to create a content can be stretched, and the corner does not stretch the picture, need two parameters, the first is not stretch the width of the area from the left border, the second parameter is not stretched the width of the area distance, its operation is the nature of a pixel copy stretching, Therefore, there is no gradient effect, which is also its disadvantage.
    3. The meaning of the parameter is if the parameter specifies 10, 5. So, the picture on the left 10 points, the top 5 points. Will not be stretched, points with an X coordinate of 11 will be copied horizontally, and a point with a Y coordinate of 6 will be copied vertically.注意:只是对一个点像素进行复制到指定的宽度。

Reference: http://www.linuxidc.com/Linux/2013-02/80113p2.htm

Methods provided by 2.IOS5

    1. -(UIImage *) Resizableimagecapinsets: (uiedgeinsets) Insets
    2. where insets the format of this parameter is (top,left,bottom,right), from the top, left, bottom and right, respectively, draw a line on the picture, so that a picture is assigned a rectangular area. Only the part inside the box is stretched, and the outside of the box remains unchanged. For example (20,5,10,5), meaning that the inner part of the rectangle can be stretched, while the rest remains unchanged.

3.IOS6 provides the method:

    1. -(UIImage *) Resizableimagewithcapinsets: (uiedgeinsets) capinsets Resizingmode: (uiimageresizingmode) ResizingMode With respect to the insets parameter, the IOS5 is the same, and the difference is that after adding a stretched pattern, the ios6.0 version provides uiimageresizingmodetile and Uiimageresizin Gmodestretch two modes, from the name can be seen, is the tiling mode and stretching mode. Tiling is the insets of the rectangular area you specify to fill the area of the picture you specify, and the stretch is to fill the area of the picture you want by stretching the block of rectangular area you insets specify. I think, compared with the progress of 4.0 you also see, is obvious, compared to the previous, the image of the resize from a point into a rectangular block, so that your specified block of the gradient effect can be presented.
    2. Just, if you need to be compatible with 4.0 of the machine, then it is necessary to use the old function to complete the resize operation of the picture.

Several ways to stretch iphone pictures

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.