- Picture Stretching method One:
How IOS 5.0 will be:
1- (void) Viewdidload {2 [Super Viewdidload];3Uiimageview *imageview =[[Uiimageview alloc] init];4Imageview.frame = CGRectMake ( -, -, -, -);5UIImage *image = [UIImage imagenamed:@"Chat_send_press_pic"];6 //IOS5.0 Incoming is the area that needs to be protected, the remainder is selected to be tiled or stretched according to Resizingmode7image = [Image Resizableimagewithcapinsets:uiedgeinsetsmake ( -, -, -, -) Resizingmode:uiimageresizingmodetile];8 9Imageview.image =image;Ten [Self.view Addsubview:imageview]; One}
- Picture Stretching method Two:
The most primitive method is also very reliable.
1- (void) Viewdidload {2 [Super Viewdidload];3Uiimageview *imageview =[[Uiimageview alloc] init];4Imageview.frame = CGRectMake ( -, -, -, -);5UIImage *image = [UIImage imagenamed:@"Chat_send_press_pic"];6 //IOS5.0 Incoming is the area that needs to be protected, the remainder is selected to be tiled or stretched according to Resizingmode7image = [Image Resizableimagewithcapinsets:uiedgeinsetsmake ( -, -, -, -) Resizingmode:uiimageresizingmodetile];8 9 //the earliest methodTen //The image width and height dimensions are generally passed in, and the system extracts the 1*1 area in the middle of the picture to stretch the fill picture . One //You can add a uiimage classification by encapsulating simplified Code Aimage = [Image StretchableImageWithLeftCapWidth:image.size.width *0.5TopCapHeight:image.size.height *0.5]; - -Imageview.image =image; the[Self.view Addsubview:imageview];
To simplify the classification created by the code
- Picture Stretching method Three:
Through, the implementation method:
The code does not change:
1- (void) Viewdidload {2 [Super Viewdidload];3Uiimageview *imageview =[[Uiimageview alloc] init];4Imageview.image = [UIImage imagenamed:@"Chat_send_press_pic"];5Imageview.frame = CGRectMake ( -, -, -, -);6 [Self.view Addsubview:imageview];7}
Edge Learning on iOS--stretching pictures