Prepare a picture in advance:
UIImage *image = [UIImageimagenamed:@ "red.png"];
This can be used before iOS 5.0:
nsinteger leftcapwidth = image. size . width * 0.5f ;
nsinteger topcapheight = image. size . Height * 0.5f ;
image = [Image stretchableimagewithleftcapwidth: leftcapwidthtopcapheight : topcapheight];
This can be used in iOS 5.0:
cgfloat top = 8;// Top Cover Height
CGFloat bottom = 8;// Bottom Cover Height
CGFloat left = 8;// Left cover width
cgfloat right = 8;// right End cover width
Uiedgeinsets insets = Uiedgeinsetsmake (top, left, bottom, right);
// Flex and assign again
image = [Image resizableimagewithcapinsets:insets];
This can be used in iOS6.0:
CGFloat top = A ; // Top Cover Height
cgfloat bottom = N; // Bottom Cover Height
cgfloat Left =ten; // Left cover width
cgfloat Right =ten; // right End cover width
uiedgeinsets insets =uiedgeinsetsmake(top, left, bottom, right);
// is specified as stretch mode, and is assigned again after scaling
image = [Image resizableimagewithcapinsets: insetsresizingmode: Uiimageresizingmodestretch];
iOS development Tutorial--How to use point 9 images