After the system is IOS6, the method for stretching the picture has been extended to 3 functions:
1.IOS4 provides the following methods:
-(UIImage *) Stretchableimagewithleftcapwidth: (Nsinteger) leftcapwidth topcapheight: (Nsinteger) topCapHeight
This function is an instance function of UIImage, its function is to create a content that can be stretched, while the corners do not stretch the picture, requires two parameters, the first is the width of the left border without stretching the area, the second parameter is the width of the top border without stretching, and its operation is essentially a copy stretching of one pixel, Therefore, there is no gradient effect, this is also its shortcomings.
The meaning of the parameter is if the parameter specifies 10, 5. So, 10 dots to the left of the picture, 5 points above. Will not be stretched, points with an X coordinate of 11 will be copied horizontally, and the points with a Y coordinate of 6 will be copied vertically. Note: Only one pixel is copied to the specified width.
The method provided by 2.ios5
-(UIImage *) Resizableimagecapinsets: (uiedgeinsets) Insets
Where insets this parameter format is (Top,left,bottom,right), from the top, left, bottom, right on the picture to draw a line, so that a picture to specify a rectangular area. Only the part of the box is stretched, and the outside of the box remains unchanged. For example (20,5,10,5), meaning that the part of the following figure rectangle can be stretched, while the rest remains unchanged.
3.IOS6 provides the following methods:
-(UIImage *) Resizableimagewithcapinsets: (uiedgeinsets) capinsets Resizingmode: (uiimageresizingmode) ResizingMode
With respect to the insets parameter, it is the same as the ios5, and the difference is that a stretch pattern is added later, and the ios6.0 version provides
The Uiimageresizingmodetile and Uiimageresizingmodestretch two modes, as can be seen from the name, are tile mode and stretch mode. Tiling is copying the rectangular area of your insets to fill in the area of the image you specify, and stretching is the area of the picture you want to fill by stretching the rectangular area you specify insets. I think, compared to 4.0 of the progress you also see it, 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 also be presented.
Just, if you need to be compatible with 4.0 of machines, then it is necessary to use the old function to complete the resize operation of the picture.