The first of these methods
//-(UIImage *) Stretchableimagewithleftcapwidth: (Nsinteger) leftcapwidth topcapheight: (Nsinteger) Topcapheight __tvos_prohibited;
//leftcapwidth: left not stretched area
//topcapheight: does not stretch the area above
UIImage *image =[UIImageimagenamed:@ " Chatdetail_info_other "];
uiimageview *imageview=[[ uiimageview alloc ] initwithframe : CGRectMake ( 20 60 size width size height
ImageView. Image =image;
[self. View addsubview: ImageView];
uiimage *image1 =[ uiimage imagenamed : @ "Chatdetail_info_other" ];
image1=[image1 Stretchableimagewithleftcapwidth :image1. size width * 0.3 topcapheight :image1. size height * 0.7 ];
uiimageview *imageview1=[[uiimageviewalloc ] initWithFrame:cgrectmake , $ , Max )];
ImageView1. Image =image1;
[self. View addsubview: imageView1];
The second method of
//-(UIImage *) Resizableimagewithcapinsets: (uiedgeinsets) capinsets Ns_available_ios (5_0);
There is a concept called end caps in iOS that specifies which part of the picture does not have to be stretched. For example , the black represents the rectangular area that needs to be stretched, and the edges that do not need to be stretched up or down are called end caps.
This method only receive a parameter of type uiedgeinsets, you can specify the left cover width, right end cover width, top cover height, bottom cover height by setting uiedgeinsets left, starboard, top, bottom respectively .
[Image1resizableimagewithcapinsets:Uiedgeinsetsmake(Image1.size.Height*0.9, Image1.size.width*0.9, Image1.size.Height*0.9, Image1.size.width*0.9)];
The third method of
//-(UIImage *) Resizableimagewithcapinsets: (uiedgeinsets) capinsets Resizingmode: (uiimageresizingmode ) Resizingmode Ns_available_ios (6_0);
// compare methods in iOS5.0, only one uiimageresizingmode parameter is used to specify the pattern of the extrusion:
//Uiimageresizingmodestretch: Stretch mode to fill a picture by stretching the rectangular area specified by the Uiedgeinsets
///Uiimageresizingmodetile: Tile mode, fills the picture by repeating the uiedgeinsets specified rectangular area
[Image1resizableimagewithcapinsets:Uiedgeinsetsmake(Image1.size.Height*0.9, Image1.size.width*0.9, Image1.size.Height*0.9, Image1.size.width*0.9)Resizingmode:Uiimageresizingmodestretch];
This code effect is the same as the second
Three ways to stretch IOS uiimage