Correct posture for iOS picture fillet settings

Source: Internet
Author: User

Recently resigned from the last company, has been in the state of being unemployed, by the way home with the girl, today there is time, so write something, I hope that the beginning of contact with the development of the iOS small white can have some gains.

Fillet images are common in iOS development, but we usually set this up when we set the rounded corners of the picture:

Uiimageview *image = [[Uiimageview alloc]initwithframe:cgrectmake (100, 100, 50, 50)];

Image.layer.cornerRadius = 25.0;

Image.layer.masksToBounds = YES;

This setting, we feel there is nothing wrong, but also to achieve the demand (fillet), but when we first started to do iOS development, often ignore the performance of the problem, this is not anything, is starting from small white. This kind of setting, especially in the cell, if the number of cells is infinite, then it is very bad, then how to solve it, we can change the line. Of course this is only part of the solution:

Uiimageview *image = [[Uiimageview alloc]initwithframe:cgrectmake (100, 100, 50, 50)];

Image.layer.cornerRadius = 25.0;

Image.layer.masksToBounds = YES;

Image.layer.shouldRasterize = YES;

Image.layer.rasterizationScale =[uiscreen Mainscreen].scale;

First of all, I need to tell you about these two properties, Rasterizationscale this property and Shouldrasterize property, I directly from the API out of it, we look at (their English proficiency Limited, haha ha):

In simple terms:

When Shouldrasterize is set to Yes, UIView will be rendered as a bitmap and cached and will not be rendered again the next time it is used. If every time the page is rendered, then it consumes too much, if shouldrasterize = YES, the next time simply read the bitmap from the cache of the rendering engine, saving system resources.

You may not feel the advantage of the latter when you have a few rounded corners, but you will suddenly feel smooth when you have an infinite number of images in your cell that need to be rounded.

Correct posture for iOS picture fillet settings

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.