STRETCHABLEIMAGEWITHLEFTCAPWIDTH:TOPCAPHEIGHT:HT;

Source: Internet
Author: User

-(UIImage *) Stretchableimagewithleftcapwidth: (Nsinteger) leftcapwidth topcapheight: (Nsinteger) topcapheight;

This method is an object method of UIImage, its function is to create a left and the upper specified area is not stretched, the UIImage object, the first parameter set the left non-extruded area, the second parameter set the upper non-extruded area. This method is typically used to create variable-width buttons and maintain the same rounded corners.

Note that the UIImage object that is generated by this method stretches when stretched by a pixel that is set at the back of the reserved area to extrude up or down. If Leftcapwidth is set to 10, then the 11th pixel on the left side of the Zola is the pixel in the row to pan left, if the topcapheight is set to 20, then the top 21st pixel in the upper row of pixels to tile down the operation, The remaining pixels are not tiled.

- (void) viewdidload{[Super Viewdidload]; UIImage* Image0 = [UIImage imagenamed:@"Searchbar_textfield_background"]; Uitextfield* TextField0 =[[Uitextfield alloc] init]; Textfield0.background=Image0; Textfield0.frame= CGRectMake ( -, -, Image0.size.width, image0.size.height);        [Self.view addsubview:textfield0]; UIImage* Image1 = [Image0 stretchableimagewithleftcapwidth:image0.size.width*0.5topcapheight:image0.size.height*0.5]; Uitextfield* TextField1 =[[Uitextfield alloc] init]; Textfield1.background=Image1; Textfield1.frame= CGRectMake ( -, -, -, -); [Self.view addsubview:textfield1];}

The effect is as follows:

STRETCHABLEIMAGEWITHLEFTCAPWIDTH:TOPCAPHEIGHT:HT;

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.