-(UIImage *) Stretchableimagewithleftcapwidth: (Nsinteger) leftcapwidth topcapheight:
(Nsinteger) Topcapheight This function is an instance function of UIImage, its function is to create a content can be stretched, and the corner does not stretch the picture, need two parameters, the first is the left not stretch the width of the area, the second parameter is not stretched above the height.
Depending on the width and height of the setting, the next pixel is extended left and right and stretched up and down.
Note: The stretchable range is 1 vertical pixels after leftcapwidth, and 1 horizontal pixels after the distance of Topcapheight.
The meaning of the parameter is if the parameter specifies 10, 5. So, the picture on the left 10 pixels, the top 5 pixels. Will not be stretched, the X coordinate is 11 and one pixel will be copied horizontally, and a pixel with a Y coordinate of 6 will be copied vertically.
Note: Only one pixel is copied to a certain width. The remaining pixels behind the image are not stretched.
UIImage *img=[uiimage imagenamed:@ "Bubbleself.png"];
Img=[img stretchableimagewithleftcapwidth:15 Topcapheight:12];
Uiimageview *imgview=[[uiimageview alloc]initwithimage:img];
[Imgview Setframe:cgrectmake (10, 10, 200, 200)];
[Self. View Addsubview:imgview];
Example:
_imageview1. Image = [[UIImage imagenamed:@ "pic_movielist_bg.9"] Stretchableimagewithleftcapwidth: topcapheight:60 ];
Put the picture
[UIImage imagenamed:@ "pic_movielist_bg.9"] stretched and
_imageview1 the same size where stretching is done by the two parameters (
Leftcapwidth,
Topcapheight
), indicating that the left 20 pixels will not be stretched above the 60 elements will not be stretchedOriginal Address http://www.cnblogs.com/bandy/archive/2012/04/25/2469369.html
Drawing of the picture Stretchableimagewithleftcapwidth