将View设置为Opaque

来源:互联网 发布:matlab编程实验答案 编辑:程序博客网 时间:2024/05/16 14:18

转自:http://www.tiboo.cn/dianzijie/b1837169/


This property 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 some drawing operations and improve performance. If set to NO, the drawing system composites the view normally with other content. The default value of this property is YES.

小属性大作用

1、opaque属性提示绘制系统如何处理view。如果opaque设置为YES,绘图系统会将
view看为完全不透明,这样绘图系统就可以优化一些绘制操作以提升性能。如果设置
为NO,那么绘图系统结合其它内容来处理view。默认情况下,这个属性是YES。)  
如果屏幕是静止的,那么这个opaque属性的设置与否不是一个大问题。但是,如果
view是嵌入到scroll view中的,或者是复杂动画的一部分,不将设置这个属性的话
肯定会影响程序的性能!  
可以通过模拟器的Debug\Color Blended Layers选项来查看哪些view没有设置为不透明。为了程序的性能,尽可能的将view设置为不透明!

2、如何将webview背景色设成透明的呢?

第一步将webview.opaque = NO

然后再将webview.backgroundColor 设为你想要的颜色

第一步很重要,否则设背景色不起作用

0 0
原创粉丝点击