IOS5 previously set stretched pictures
-(void) loadimagebeforeios5{
//35*30
UIButton *nextbutton = [[UIButton alloc] initwithframe:cgrectmake( ( n . )
[Nextbutton settitle:@ "IOS5 before " forstate:uicontrolstatenormal];
Nextbutton. layer. BorderColor=[[uicolor redcolor] cgcolor];
Nextbutton. layer. BorderWidth=1.0f;
UIImage *image = [UIImage imagenamed:@ "Question"];
// Set left End cover width rightcap=width-leftcapwidth-1
Nsinteger leftcapwidth = image. Size. Width * 0.5;
// set Top End cap height bottom=height-topcapwidth-1
Nsinteger topcapheight = image. Size. Height * 0.5;
UIImage *newimage = [Image stretchableimagewithleftcapwidth: leftcapwidth topcapheight : Topcapheight];
[Nextbutton setbackgroundimage: NewImage forstate:uicontrolstatenormal];
[self. View addsubview: Nextbutton];
}
IOS5 Stretching Pictures
-(void) loadimageios5{
UIImage *image = [UIImage imagenamed:@ "Question"];
UIButton *resizablebutton=[[UIButton alloc]initwithframe:cgrectmake( (+ );
[Resizablebutton settitle:@ "iOS5" forstate:uicontrolstatenormal];
// Set the value of the end cap
cgfloat top = image. Size. Height * 0.5;
CGFloat Left = image. Size. Width * 0.5;
cgfloat bottom = image. Size. Height * 0.5;
cgfloat Right = image. Size. Width * 0.5;
uiedgeinsets edgeinsets = uiedgeinsetsmake(top, left, bottom, right);
// stretch picture
UIImage *edgeimage = [Image resizableimagewithcapinsets: edgeinsets];
// Set the background image of the button
[Resizablebutton setbackgroundimage: Edgeimage forstate:uicontrolstatenormal];
[self. View addsubview: Resizablebutton];
}
IOS6 Stretching Pictures
-(void) loadimageafterios6{
UIImage *image = [UIImage imagenamed:@ "Question"];
UIButton *resizablebuttonmode=[[UIButton alloc]initwithframe:cgrectmake (+, +, +- )];
[Resizablebuttonmode settitle:@ "iOS6" forstate:uicontrolstatenormal];
[Resizablebuttonmode addTarget:self action:@selector(buttonpressed:) forcontrolevents:uicontroleventtouchupinside];
// set upper left lower right margin
cgfloat topmode= image. Size. Height * 0.5;
cgfloat leftmode= image. Size. Width * 0.5;
cgfloat bottommode= image. Size. Height * 0.5;
cgfloat rightmode= image. Size. Width * 0.5;
uiedgeinsets edgeinsetsmode= uiedgeinsetsmake(Topmode, Leftmode, Bottommode, Rightmode);
// stretch picture
UIImage *edgemodeimage = [Image resizableimagewithcapinsets: Edgeinsetsmode Resizingmode :uiimageresizingmodestretch];
UIImage *edgemodeimage = [Image Resizableimagewithcapinsets:edgeinsetsmode Resizingmode:uiimageresizingmodetile];
// set picture
[Resizablebuttonmode setbackgroundimage: Edgemodeimage forstate:uicontrolstatenormal];
[self. View addsubview: Resizablebuttonmode];
}
Image Image Stretch