IOS UIImage Stretching issues (for UIButton, etc. where local stretching is required)

Source: Internet
Author: User

Pictures have a large cut of the image is also occupied the size of the IPA, sometimes transduction only need to local or a compressed picture of the abstract state

Directly on the code

CGFloat top =Ten;//Top Cover HeightCGFloat Bottom=Ten;//Bottom Cover HeightCGFloat Left=Ten;//Left cover widthCGFloat Right=Ten;//right End cover widthuiedgeinsets insets=Uiedgeinsetsmake (top, left, bottom, right);[OptionButton setbackgroundimage:[[uiimage imagenamed:@"Hf_segment_control_left_normal"] resizableimagewithcapinsets:insets] forstate:uicontrolstatenormal];

//uiimageresizingmodestretch: Stretch mode to fill a picture by stretching the rectangular area specified by the Uiedgeinsets
//uiimageresizingmodetile: Tile mode, fills the map by repeating the uiedgeinsets specified rectangular area

A picture of the web, with an elephant tells you the existence of four width parameters, stretching is the middle black common zone

My sister on the use of the result map

: Product Manager Design Good beauty I like this style.

That's what it's like to have a very harmonious feeling after stretching.

Error Demonstration:

This picture has always been the size and proportions of the original image, I was crazy for a while, questioned why do not stretch the original to let the image stretch to use [UIButton setbackgroundimage:] I use is setimage: Can not make a big mistake, Setbackgroudim Age is the background tile setimage is the display of the picture. That is , the picture will not enlarge with the button, the picture is always the original image size, and the picture is set with the SetBackgroundImage method, and the picture will be enlarged as the button becomes larger.

Up posture haha setimage: Just the left is the picture to the right is Button.title

For example: Good beauty

IOS UIImage Stretching issues (for UIButton, etc. where local stretching is required)

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.