2017-02-10 79 views
3

在Apple的Core Animation文檔中,它說有兩個渲染路徑。據我所知,CALayer會緩存UIView內容的位圖數據。有兩種方式提供CALayer的內容。一種是實現drawRect:或其他CALayer繪圖方法,另一種是將位圖設置爲CALayer的屬性內容。UIView/CALayer如何在不使用drawRect的情況下呈現自己:?

在這裏,我想知道,如果上述兩件事情都沒有完成,幕後會發生什麼?我相信在這種情況下使用私人繪圖路徑UIView。這個私人繪圖路徑由什麼組成?它是如何工作的?

回答

0

有三種方式爲圖層提供內容。 - Assign an image object directly to the layer object’s contents property. - Assign a delegate object to the layer and let the delegate draw the layer’s content. - Define a layer subclass and override one of its drawing methods to provide the layer contents yourself. 如果我們沒有實現drawRect:或設置contents屬性或圖層的子類,它將使用默認方式,這是第二種將內容提供給圖層支持的視圖圖層的默認方式。該圖層將捕獲視圖的內容並進行渲染。

相關問題