iOS picture Stretch method (5.0-6.0)

Source: Internet
Author: User

First, IOS 5.0

In iOS 5.0, UIImage also has a new way to handle picture stretching issues

-(UIImage *) Resizableimagewithcapinsets: (uiedgeinsets) capinsets

This method only receives a uiedgeinsets type parameter, which can be specified by setting the left, right, top and bottom of the uiedgeinsets, respectively, by specifying the width of the left cover, the width of the end cap, the top cover height, the bottom cover height

1 CGFloat top = 25; Top cover Height 2 cgfloat bottom = 25; Bottom cover Height 3 cgfloat left = 10; Left cover width 4 cgfloat right = 10; Right End cover Width 5 uiedgeinsets insets = Uiedgeinsetsmake (top, left, bottom, right), 6//re-assigned value after scaling 7 image = [Image Resizableimagewith Capinsets:insets];

Operating effect:

Second, IOS 6.0

In iOS6.0, UIImage also provides a way to process picture stretching

-(UIImage *) Resizableimagewithcapinsets: (uiedgeinsets) capinsets Resizingmode: (uiimageresizingmode) ResizingMode

Comparing the methods in iOS5.0, only one more Uiimageresizingmode parameter is used to specify the pattern of the extrusion:

    • Uiimageresizingmodestretch: Stretch mode to fill a picture by stretching the rectangular area specified by the Uiedgeinsets
    • Uiimageresizingmodetile: Tile mode, fills the picture by repeating the uiedgeinsets specified rectangular area
1 CGFloat top = 25; Top cover Height 2 cgfloat bottom = 25; Bottom cover Height 3 cgfloat left = 10; Left cover width 4 cgfloat right = 10; Right End cover Width 5 uiedgeinsets insets = Uiedgeinsetsmake (top, left, bottom, right), 6//specified as stretch mode, re-assigned value after scaling 7 image = [Image Resizablei Magewithcapinsets:insets Resizingmode:uiimageresizingmodestretch];

Operating effect:

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.