Image Image Stretch

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.