IOS UIImage Some Learning essentials for local stretching of pictures

Source: Internet
Author: User

Before doing a solid-color local stretch the shadow stretching through top bottom left right intersects

Implementation method:

Imageview.image = [[UIImage imagenamed: @ "Icon_helper_palace_day"] resizableimagewithcapinsets:palaceinset]];

I use this method to stretch a patterned figure of the relative solid color of the part of the time will find that the picture is stretched at the same time there will be a picture of the local itself filled with the phenomenon seems to be continuous with the same 1 half a figure

This time, I'm not taking into account a property of the stretch picture uiimage

:

typedef ns_enum (Nsinteger, Uiimageresizingmode) {

Uiimageresizingmodetile,//进行区域复制模式拉伸 "填充"

uiimageresizingmodestretch,//进行渐变复制模式拉伸 "拉伸"

};

The default property is that the one that is obviously the pixel fill is suitable for a solid fill stretch, so the rest of the stretch should be used with your stretch property.

Implemented as follows:

Imageview.image = [[UIImage imagenamed:@ "Icon_helper_palace_day"] Resizableimagewithcapinsets:palaceinset Resizingmode:uiimageresizingmodestretch];

Really is La Biolu (the background palace stretches the Red wall section)

This is a good deal of local image processing, but the same picture obtained from the network using the same method as follows:

The palace is at the bottom, but it's not visible after stretching. Just this is why I study half a day even myself wrote a demo intended to help netizens, I suddenly found that the online transmission of the picture is xx.png and the local picture is @2x @3x This is the key difference!!!! Description Code Very honest expression of this embarrassing situation , for the network download Xx.png app must default to the original image is "@1x" one times, then I would like to let him as the local image effect must be processed proportionally cut can:

UIImage *iconimage = [Hfimageutil scaletosize:image newsize:[uiimage imagenamed:@ "Icon_helper_palace_day"]. Size]; The size of the application level of the 2x or 3x local graph obtained by the current application is cropped

It's going to stretch out and then it's normal.

IOS UIImage Some Learning essentials for local stretching of pictures

Related Article

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.