First, IOS 5.0
In iOS 5.0, UIImage also has a new way to handle picture stretching issues
-(UIImage *) Resizableimagewithcapinsets: (uiedgeinsets) capinsets
This method only receives a uiedgeinsets type parameter, which can be specified by setting the left, right, top and bottom of the uiedgeinsets, respectively, by specifying the width of the left cover, the width of the end cap, the top cover height, the bottom cover height
1 CGFloat top = 25; Top cover Height 2 cgfloat bottom = 25; Bottom cover Height 3 cgfloat left = 10; Left cover width 4 cgfloat right = 10; Right End cover Width 5 uiedgeinsets insets = Uiedgeinsetsmake (top, left, bottom, right), 6//re-assigned value after scaling 7 image = [Image Resizableimagewith Capinsets:insets];
Operating effect:
Second, IOS 6.0
In iOS6.0, UIImage also provides a way to process picture stretching
-(UIImage *) Resizableimagewithcapinsets: (uiedgeinsets) capinsets Resizingmode: (uiimageresizingmode) ResizingMode
Comparing the methods in iOS5.0, only one more 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
1 CGFloat top = 25; Top cover Height 2 cgfloat bottom = 25; Bottom cover Height 3 cgfloat left = 10; Left cover width 4 cgfloat right = 10; Right End cover Width 5 uiedgeinsets insets = Uiedgeinsetsmake (top, left, bottom, right), 6//specified as stretch mode, re-assigned value after scaling 7 image = [Image Resizablei Magewithcapinsets:insets Resizingmode:uiimageresizingmodestretch];
Operating effect: