將View設置爲Opaque

轉自: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 設爲你想要的顏色

第一步很重要,否則設背景色不起作用

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章