[BS-16] Try to set the view's opaque property to Yes (default is YES)

Source: Internet
Author: User

Try to set the view's opaque property to Yes (default is YES)

The UIView control has a opaque property, and if you do not change the transparency of the view, you should set its opaque property to Yes. Why do you want to do this? There is a certain reason for it, let's have a look. Setting up iOS allows the system to draw the view in an optimal way. The opaque property can be set in Interface Builder or code.

 
Apple's Official document has the following explanation for the opaque attribute:

The provides a hint to the drawing system as to how it should treat the view. If set to YES, the drawing system treats the view as fully opaque, which allows the drawing system to optimize SOM E drawing operations and improve performance. If set to NO, the drawing system composites the view normally and other content. The default value of the is YES.

An opaque view are expected to fill their bounds with entirely opaque content-that are, the content should has an alpha value of 1.0. If The view is opaque and either does isn't fill its bounds or contains wholly or partially transparent content, the results is unpredictable. You should always set the value of this property to NO If the view is fully or partially transparent.

You have need to set a value for the opaque property in subclasses of UIView that draw their own content using the DrawRect: method. The opaque property had no effect in system-provided classes such as UIButton, UILabel, uitable Viewcell, and so on.

(The Opaque property hints at how the system handles view.) If opaque is set to Yes, the drawing system will see view as completely opaque, so the drawing system can optimize some of the drawing operations to improve performance. If set to no, the drawing system handles the view in conjunction with other content. By default, this property is yes. )

 
If the screen is still, the setting of this opaque property is not a big problem. However, if the view is embedded in scroll view, or is part of a complex animation, setting this property will certainly affect the performance of the program!


You can see which view is not set to opaque through the emulator's Debug\color blended layers option. For the performance of the program, set the view as opaque as possible!

[BS-16] Try to set the view's opaque property to Yes (default is YES)

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.