來自 https://robots.thoughtbot.com/designing-for-ios-graphics-performance
以下情形,iOS會自動進行離屏渲染:
Core Graphics (any class prefixed with CG*)
The drawRect() method, even with an empty implementation.
CALayers with a shouldRasterize property set to YES.
CALayers using masks (setMasksToBounds) and dynamic shadows (setShadow*).
Any text displayed on screen, including Core Text.
Group opacity (UIViewGroupOpacity).
我們可以通過兩種方法發(fā)現(xiàn)自己app哪些界面發(fā)生了離屏渲染:
1、通過Xcode自帶工具Instruments(Xcode->Open Developer Tool->Instruments),打開Core Animation模板,如下圖片:

點擊底部工具欄Debug Options,從彈出菜單中選擇Color Offscreen-Rendered Yellow
2、比較簡單,用模擬器調(diào)試的時候,打開菜單Debug > Color Offscreen-Rendered選項。